knitr::opts_chunk$set(echo = TRUE)
Called my package smallpackage in RStudio. File > New Project… > New Directory > R package
library(devtools) install(".") library("smallpackage") #use the inbuilt function! hello()
You can insert a Roxygen skeleton by placing the cursor with a function and clicking:
Code > Insert Roxygen Skeleton
Delete the original NAMESPACE and help files that came with the template.
After you have one or more functions with skeletons,use function devtools::document() to create documentation. This re-creates a hello.Rd helpfile in the man/ folder and populates the NAMESPACE with our functions
devtools::document() #Add rgdal as a dependency. usethis::use_package("rgdal") library(usethis) use_gpl_license(version = 3, include_future = TRUE) citation("smallpackage") usethis::use_readme_rmd() devtools::check()
Citation will not work very well until you edit the DESCRIPTION file.
First complete the authors. Remove the current author and maintainer lines and replace it with the following line:
Authors@R: person("First", "Last", email = "first.last@example.com", role = c("aut", "cre"))
Complete the title and description fields with appropriate details. If you want to form a paragraph of text, make sure do indent the hanging lines by 4 spaces (one tab). And make sure that your Description field ends in a full-stop. Add a date
Use today’s date in ISO format, ie 2019-04-10. This will populate a citation entry for us.
usethis::use_vignette("second-vignette")
Or, go through the RStudio menu File -> New File -> R Markdown -> From Template. Then you select “Package Vignette” from the rmarkdown package, and you will get a vignette template. After changing the title, author, and other metadata of the template, you can start writing the content of your report.
DO NOT JUST KNIT A VIGNETTE USING THE BUTTON
You can build all vignettes from the console with devtools::build_vignettes(), but this is rarely useful. Instead use devtools::build() to create a package bundle with the vignettes included. RStudio’s “Build & reload” does not build vignettes to save time. Similarly, devtools::install_github() (and friends) will not build vignettes by default because they’re time consuming and may require additional packages. You can force building with devtools::install_github(build_vignettes = TRUE). This will also install all suggested packages.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.