Skip to contents
library(SWMadagascar)

Include some data examples in your package

The first function of the package: Calculate the median of a vector

my_median(1:12)
#> [1] 6.5

# Example with your dataset in "inst/"
datafile <- system.file("nyc_squirrels_sample.csv", package = "SWMadagascar")
nyc_squirrels <- read.csv(datafile, encoding = "UTF-8")
# Apply my function
my_median(nyc_squirrels[, "hectare_squirrel_number"])
#> [1] 3

Calculate the mean of a vector

Use sub-functions in the same chunk

my_other_median(1:12)
#> [1] 6.5

Inflate your package

You’re one inflate from paper to box. Build your package from this very Rmd using fusen::inflate()

  • Verify your "DESCRIPTION" file has been updated
  • Verify your function is in "R/" directory
  • Verify your test is in "tests/testthat/" directory
  • Verify this Rmd appears in "vignettes/" directory