I thought that putting an internal dataset for a package into R/sysdata.rda
would make the data accessible to my functions. But I can't seem to figure out how to actually access this dataframe. None of the documentation actually says how to access the data, but my guess was that I could simply refer to the dataframe by name. However, this does not seem to work.
I used devtools::use_data()
with internal = TRUE
and sysdata.rda was created. Lazy-loading is set to TRUE.
To test it, I manually loaded it just to make sure it was the right file. The file is called nhanes_files
. Within my function, I simply refer to the nhanes_files
object and extract the necessary data. When I tested my function in my package project, it seemed to work. When I build and load the package, upload to GitHub, and then install the package into a new project, I get an error: Error in find_data() : object 'nhanes_files' not found
Do I need to do something else to make this internal data accessible to my functions?
Below is the most basic function, which is not working:
#' Print NHANES file listing
#'
#' Provides access to the internal data listing all NHANES files
#'
#' @return A data frame with the list of files that can be accessed through the NHANES website. Should not generally be used. Present for debugging purposes and transparency.
#' @export
find_data <- function(){
nhanes_files
}