R and roxygen2: How to document data files in inst/extdata?
Asked Answered
T

1

6

I have some data files that I want to distribute with a package I'm creating. I've placed the files in inst/extdata. How and where do I document these files using roxygen2?

Trickster answered 12/2, 2016 at 22:25 Comment(8)
r-pkgs.had.co.nz/data.htmlPectin
There is nothing there I can see about how to document raw data. I've followed the R Packages book closely while developing, so of course - I've read that page :)Trickster
exactly the same as you do data in /data except give it a @name raw_data1 to reference and a NULL value instead of "raw_data1"Capon
Thank you. Do I do that in a file R/data.R? Is this correct? How do I reference the filename I have in inst/extdata?Trickster
looks fine, you can put it in any script in /r. Then you can ?raw_myDataset to bring up that help page. I'm not sure what you mean by reference it. you can get the file path with system.file('extdata','raw_data1.csv', package = 'your_package'), is that what you mean?Capon
Thank you for answering. Is there a tag name that's used to point to the specific file in inst/extdata that I'm documenting? If my dataset is inst/extdata/rollerblades.csv, something like this?Trickster
what do you mean by point to it, what do you expect that to do? in your package it would just be a csv file, you'd have to write something to read/print or load that data if that's what you're expecting--similar behavior as data/rollerblades.Rdata?Capon
Since I'm going to document the file inst/extdata/rollerblades.csv in another file, say R/data.R, I was thinking there must be some established way to refer to the data file from the documentation. Like the the tag @dataFilename I used in that example. But maybe it doesn't matter. Thank you for the help!Trickster
T
2

I'm still not sure what's best practice, but following rawr's advice this is what I did:

  • Created a file R/extdata.R
  • Documented each file I have in inst/extdata like this:

(Ignore this line: Apparently I need some text here so that what's below turns into a code block.)

#' Dataset foo
#'
#' This is a dataset containing stuff.
#'
#' @name raw_datasetName
#'
#' @section datasetName.csv:
#'
#' This data is used in thisFunction().
NULL
Trickster answered 29/3, 2016 at 12:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.