2

Using roxygen2 and devtools to author my own package.

I have some data I would like to include with my package (stored at data/mydata.rda).

I have documented this data in roxygen format at R/mydata.R:

#'This is my data
#'
#'This is my description
#'
#'@name mydata
#'@docType data
##### omitting @format for brevity
"mydata"

In DESCRIPTION, I have LazyData: true

Yet when I run document(), I get an error message that "mydata is not an exported object from 'namespace: mypackage'"

What gives? Hadley's guide says never to export data, and you are not supposed to directly edit NAMESPACE when using roxygen2, so I am at a bit of a loss.

user1569317
  • 2,436
  • 3
  • 14
  • 17
  • Please try to make a minimal [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) so we can see exactly what you've attempted and can re-create the error ourselves so we can test and offer a specific solution. – MrFlick Feb 16 '17 at 15:51
  • @J_F I was not, but adding `@name mydata` did not resolve the problem – user1569317 Feb 16 '17 at 15:55
  • This fixed it - if you write it as a comment, I will accept it as the answer. Mind explaining why this works so it is not pure magic? – user1569317 Feb 16 '17 at 16:07
  • I retract the previous comment - still is not working. – user1569317 Feb 16 '17 at 16:13
  • Did you have mydata.R exported in the DESCRIPTION? If you have the "Collate" filed, you also have to write `mydata.R' here. – J_F Feb 16 '17 at 16:30
  • You don't export things in DESCRIPTION. And the documentation explicitly says to not @export data in the .R file. – user1569317 Feb 16 '17 at 16:36
  • I don't mean export in that way using @export. See for example here: https://github.com/tidyverse/ggplot2/blob/master/R/data.R and then they also mention data.R in Collate in their DESCRIPTION file. – J_F Feb 16 '17 at 16:41

0 Answers0