6

I am working with roxygen2 library and devtools. Building a package with the following structure:

  • Inside /data folder I have two .rda files with the information of each dataset. Let's call them data1.rda and data2.rda.
  • Inside /R folder I have two files, one with the functions created (and their explanation) and another one called data.R with the information of each dataset.

    #' Description 1
    #'
    #' Simple definition
    #'
    #' @format The \code{data.frame} contains 2 variables:
    #' \describe{
    #'   \item{a}{The first variable.}
    #'   \item{b}{The second variable.}
    #' }
      "data1"
    

When I run roxygen2::roxygenize() I get this message:

First time using roxygen2. Upgrading automatically... Error in get(name, envir = env) : object 'data1' not found.

I have looked for similar questions, without an answer for this problem. Anyone has a suggestion?

R18
  • 1,476
  • 1
  • 8
  • 17
  • Does it work if you add `@keywords data` to the end of `#'` block? – Paolo Apr 19 '17 at 13:14
  • @pdil No, it doesn't. – R18 Apr 19 '17 at 13:19
  • Do you have that empty line in your actual roxygen comments? – Dason Apr 19 '17 at 13:25
  • No, I don't. I have edited the line not to confuse. – R18 Apr 19 '17 at 13:28
  • Typically doesn't one just use NULL under the roxygen documentation for datasets? If you do that does it work? – Dason Apr 19 '17 at 13:40
  • 2
    http://stackoverflow.com/questions/2310409/how-can-i-document-data-sets-with-roxygen – Dason Apr 19 '17 at 13:45
  • @Dason Thank you, It worked following the suggested link. It is strange that the traditional way indicated in http://blog.runsheng.xyz/attachment/r-packages.pdf doesn't work. – R18 Apr 19 '17 at 13:53
  • @R18 that's weird, in my package I used the data set name in quotes and it worked, https://github.com/pdil/usmap/blob/master/R/datasets.R – Paolo Apr 19 '17 at 14:01
  • I suggested that since it seems the issue is that it's trying to "get" the data from the name you provide and that causes an error. I don't deal with including data enough to have a good example to play around with this but it seemed like avoiding that step would help alleviate this particular problem (but it seems like it shouldn't have been a problem so it might just be creating a problem later on). You might want to check that your package can install fine and the data gets loaded properly and you can view the documentation for the data. – Dason Apr 19 '17 at 14:03
  • I wonder if it's because you were missing `@docType data` – Paolo Apr 19 '17 at 14:03
  • @pdil I didn't write `@datatype` and `@name'. Could the problem come from this? – R18 Apr 19 '17 at 14:03
  • @R18 Not sure actually, if you go to this [vignette](https://cran.r-project.org/web/packages/roxygen2/vignettes/rd.html) and go to "Documenting datasets" he doesn't use any of those `@` words and even has the name in quotes. – Paolo Apr 19 '17 at 14:06
  • @R18 is your package on github? It would be a lot easier to actually see your code than trying to guess at what could be going on. – Dason Apr 19 '17 at 14:09
  • @Dason No, I'm still developing the functions for the package. Without `@doctype` it still works. It is like if it prefers to give `@name` rather than defining it between `" "` at the end of the code. – R18 Apr 19 '17 at 14:14
  • @R18 It can be on github while still in development. It would certainly make helping debug this issue easier for others :) – Dason Apr 19 '17 at 14:17

3 Answers3

4

It might be a silly question but are you running roxygenise on your loaded package? Meaning that you first run devtools::load_all(), and then roxygen2::roxygenise(). I've seen a couple of people making this mistake on other posts.

FilipeTeixeira
  • 1,100
  • 2
  • 9
  • 29
0

The roxygen2::roxygenize method does not load the package properly. But you can replace this step with devtools::document(package_path)

Mini Fridge
  • 919
  • 12
  • 24
0

Please try adding these additional tags in your comments: @name, @docType, and @references