Data not exported from namespace in R
for data objects, the names must match in four (4) places, so check them all:
- name of data/foo.rda file
- name of object in data/foo.rda file
name of R/foo.R file- string at end of R/foo.R file
all four items must match--in this case 'foo'. If you change the name of the foo.rda and foo.R files, say to bar.rda and bar.R, it's easy to forget to rename the object in the .rda file from 'foo' to 'bar.' It's usually easiest to load the file, rename the object, and save the file under the new name:
load('data/foo.rda')
bar <- foo
save(bar, file='data/bar.rda')
If you don't do this, you get an unhelpful error about the object not loaded from namespace. You DON'T need to @export data objects, so instead ensure the names match in all places.
I encountered a similar problem when writing an R package which contains a dataset. I guess you must have saved the dataset in a different name.
For example, you may write:
devtools:::use_data(YourDataSetName, pkg = "Path_to_Pkg/data", internal = FALSE)
but in your data.R
file, you specified a dataset name at the very end other than YourDataSetName
(suppose you followed Hadley's instructions here: http://r-pkgs.had.co.nz/data.html).
Make sure the data object you saved to the "data" folder is the same as you specified in your data.R
file.
Note: use_data is now part of usethis package.