Data not found in documentation with roxygen2
Asked Answered
M

3

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?

Mertens answered 19/4, 2017 at 12:40 Comment(15)
Does it work if you add @keywords data to the end of #' block?Shooin
@pdil No, it doesn't.Mertens
Do you have that empty line in your actual roxygen comments?Thallophyte
No, I don't. I have edited the line not to confuse.Mertens
Typically doesn't one just use NULL under the roxygen documentation for datasets? If you do that does it work?Thallophyte
#2310909Thallophyte
@Thallophyte Thank you, It worked following the suggested link. It is strange that the traditional way indicated in blog.runsheng.xyz/attachment/r-packages.pdf doesn't work.Mertens
@Mertens that's weird, in my package I used the data set name in quotes and it worked, github.com/pdil/usmap/blob/master/R/datasets.RShooin
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.Thallophyte
I wonder if it's because you were missing @docType dataShooin
@pdil I didn't write @datatype and `@name'. Could the problem come from this?Mertens
@Mertens Not sure actually, if you go to this vignette and go to "Documenting datasets" he doesn't use any of those @ words and even has the name in quotes.Shooin
@Mertens 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.Thallophyte
@Thallophyte 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.Mertens
@Mertens It can be on github while still in development. It would certainly make helping debug this issue easier for others :)Thallophyte
S
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.

Spae answered 13/9, 2017 at 17:39 Comment(0)
R
0

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

Reasoning answered 19/4, 2018 at 11:56 Comment(0)
W
0

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

Wellesley answered 18/9, 2021 at 18:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.