knitr::opts_chunk$set( echo = TRUE, eval = FALSE, warning = FALSE, message = FALSE )
library(devtools) library(usethis) library(writethat) usethis::create_package(path = '.')
writethat::use_r.function('R/myfun.R')
#' #BEGIN: documentation #' this will be in the \\title{} section #' #' this will be in the \\description{} section #' #' @param arg1 [any] an argument to be printed #' @param arg2 [any] another argument to be printed #' @return NULL #' #' @usage my_metadoc_fun(arg1 = NULL, arg2 = "value2") #' #' # if @export present, this function will be exported #' @export #END: documentation #BEGIN: code my_metadoc_fun = function(arg1 = NULL, arg2 = "value2") { cat(sprintf('my_metadoc_fun called:\n')) cat(sprintf('arg1:\n')) print(arg1) cat(sprintf('arg2:\n')) print(arg1) } #END: code #BEGIN: examples #' @examples #' # a first example #' my_metadoc_fun() #' #' # an example with arguments passed by position #' a_value = 3 #' my_metadoc_fun(a_value) #' #' # an example with arguments passed by keyword #' a_value = 3 #' my_metadoc_fun(arg1 = a_value) #' #END: examples
writethat::reformat_packaging('R/myfun.R',dry_run = FALSE)
devtools::build() devtools::check()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.