library(devtools) pkg<-"newPackage" create(pkg) library(devtools) # Open the project! add_test_infrastructure() # Add unit test framework add_travis() # Add CI framework use_vignette() # Add folder for macro-level help files use_package_doc() # Add file for providing info about your package use_readme_rmd() # Make a README!
myfunc<-function(a=1,b=2,c="blah"){ stopifnot(is.numeric(a), is.numeric(b), is.character(c)) d<-ifelse(a<0,a*b,a/b) e<-paste0(c,d) return(e) } library(testthat) # Add a high-level name for group of tests, typically the function name context("myfunc") # Simplest test test_that("Defaults return expected result",{ result<-myfunc() check<-"blah0.5" expect_equal(result,check) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.