How to start a new package with testing in R

May 30, 2019

(This article was first published on triKnowBits, and kindly contributed to R-bloggers)

# Navigate where you want your folder to be located
# Assumes usethis is installed
# Say yes or no to next (annoying) popup window, it doesn’t matter.
# Add a test environment
# Add first test function to at least get something in that folder.
# Go to foo\tests\testthat
# and add this file.
test_that(“I’m testing something”, {
  # do something with your code
  expect_equal(1:4, 1:4)

# Done

# Don’t forget!
# The only thing roxygen doesn’t handle is, 
# whenever you add new functionality from another package, 
# you have have to change DESCRIPTION.

To leave a comment for the author, please follow the link and comment on their blog: triKnowBits. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)