1

I want to include a dataset in a package I'm building. I followed all the steps in this primer.

  • Create a data subdirectory and save the dataset as myPackage/data/this_dataset.Rdata
  • Create a .R file with Roxygen2 comments, saved as myPackage/R/this_dataset-data.R
  • Include the line LazyData: true in the DESCRIPTION file.

Then I install it:

> library("devtools")
> setwd("D:/workspace/myPackage")
> install()
Installing aPackage
Skipping 1 package ahead of CRAN: data.table
"C:/PROGRA~1/R/R-32~1.3/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD INSTALL  \
  "D:/workspace/myPackage" --library="C:/Users/aUser/Documents/R/win-library/3.2" --install-tests 

* installing *source* package 'aPackage' ...
** R
** data
*** moving datasets to lazyload DB
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (aPackage)

Reloading installed aPackage

So it looks like it figured out that there are datasets.

But then I can't get the dataset to load. print(this_dataset) should work with lazy loading but returns "object not found" error. data(this_dataset) returns "data set not found." I do: data(package='aPackage') and get no data sets found.

What am I doing wrong?

C8H10N4O2
  • 18,312
  • 8
  • 98
  • 134
  • 1
    How does the NAMESPACE file look like? – drmariod Feb 17 '16 at 20:43
  • @drmariod all the NAMESPACE file contains is `exportPattern("^[[:alpha:]]+")` -- Maybe that is making my dataset fail since its name contains an underscore? – C8H10N4O2 Feb 17 '16 at 20:54
  • @drmariod I tried changing the NAMESPACE to a different export pattern like `exportPattern("^[^\\.]")` mentioned in [this answer](http://stackoverflow.com/a/13436284/2573061) but no difference – C8H10N4O2 Feb 17 '16 at 21:04
  • the namespace doesnt have anything to do with data sets.. silly question but you are _building_ the package before you install it, correct? – rawr Feb 17 '16 at 22:18
  • How does sour `.R` file for the data look like? Does it has `@docType data`, `@keywords datasets`, `@format A data frame with 95 rows and 32 variables` and `@name proteinGroups` as parameters (not sure if you need them all but this is what I set)? And I normally add a `NULL` after the comment block. – drmariod Feb 18 '16 at 07:49

1 Answers1

2

I'm not sure why it mattered, but changing the file name from myPackage/data/this_dataset.Rdata to myPackage/data/this_dataset.RData (note difference in capitalization of file extension) seems to have made the difference.

C8H10N4O2
  • 18,312
  • 8
  • 98
  • 134