Before I take a crack at this, I would like to reiterate what others are saying. R's package system is literally exactly what you are looking for. It is used successfully by many to distribute just data and no code. Combined with R's lazyloading of data, you can distribute large datasets as packages and not burden users who don't wish to load it all.
In addition, you will not be able to take advantage of R's help system unless you use packages. The original question explicitly asks about using ?myData
and your users will not be able to do that if you do not use a package. This is quite simply a limitation of R's base help function.
Now, to answer the question. You will need to use some non-exported roxygen functions to make this work, but it's not too onerous. In addition, you'll need to put your R file(s) documenting your data into a folder of their own somewhere, and within that folder you will want to create an empty folder called man
.
Example directory structure:
# ./
# ./man/
# ./myData.R
# ./otherData.R
myData.R
#' My dataset
#'
#' This is data I like.
#'
#' @name myData
NULL
otherData.R:
#' My other dataset
#'
#' This is another dataset I like
#'
#' @name otherData
NULL
Now, the code that will bring it all together (and you can of course wrap this in a function):
library(roxygen2)
mydir <- "path/to/your/data/directory/"
myfiles <- c("myData.R","otherData.R")
# get parsed source into roxygen-friendly format
env <- new.env(parent = globalenv())
rfiles <- sapply(myfiles, function(f) file.path(mydir,f))
blocks <- unlist(lapply(rfiles, roxygen2:::parse_file, env=env), recursive=FALSE)
parsed <- list(env=env, blocks=blocks)
# parse roxygen comments into rd files and output then into the "./man" directory
roc <- roxygen2:::rd_roclet()
results <- roxygen2:::roc_process(roc, parsed, mydir)
roxygen2:::roc_output(roc, results, mydir, options=list(wrap=FALSE), check = FALSE)
You should now have properly formatted myData.Rd
and otherData.Rd
files in the once-empty man
folder.
ggplot2
without installingggplot2
? – Cotquean