Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setClassUnion causes missing name error. #514

Closed
johnpauls opened this issue Sep 21, 2016 · 5 comments
Closed

setClassUnion causes missing name error. #514

johnpauls opened this issue Sep 21, 2016 · 5 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@johnpauls
Copy link

If you have a setClassUnion statement in your code, roxygen2 (version 5.0.1) will throw a missing name error when you build the package (done using RStudio 0.99.903, on a Windows 7 machine). If you move the setClassUnion statement above of all the roxygen2 documentation statemetns , i.e. everything starting #' @xxxx then the error goes away. If you are just trying to document a class union, then the documentation is not produced.

@hadley
Copy link
Member

hadley commented Sep 21, 2016

Please provide a reproducible example. There are three things you need to include to make your example reproducible: required packages, data, and code.

  1. Packages should be loaded at the top of the script, so it's easy to
    see which ones the example needs. This is a good time to check that you're
    using the latest version of each package: it's possible you've discovered
    a bug that been fixed since you installed the package.
  2. The easiest way to include data in a question is to use dput() to
    generate the R code to recreate it. For example, to recreate the mtcars
    dataset in R, I'd perform the following steps:
  3. Run dput(mtcars) in R
  4. Copy the output
  5. In my reproducible script, type mtcars <- then paste.

Try and find the smallest subset of your data that still reveals
the problem.
3. Spend a little bit of time ensuring that your code is easy for others to
read:

  • Make sure you've used spaces and your variable names are concise, yet
    informative.
  • Use comments to indicate where your problem lies.
  • Do your best to remove everything that is not related to the problem.
    The shorter your code is, the easier it is to understand, and the
    easier it is to fix.

Finish by checking that you have actually made a reproducible example by starting a fresh R session and copying and pasting your script in.

@hadley hadley added the bug an unexpected problem or unintended behavior label Sep 21, 2016
@hadley hadley closed this as completed in be633d7 Sep 21, 2016
@hadley
Copy link
Member

hadley commented Sep 21, 2016

I took a stab in the dark — I think this will probably fix your problem

@johnpauls
Copy link
Author

johnpauls commented Sep 21, 2016

Sorry,
Here is an example that will cause the error. When you try to build a package which includes this as a standalone file, you get a "Missing Name' error. As far as I can tell it does not matter what the members of the union are. If you move the SetClassUnion function to the top of the file, then the package will build, but no documentation will be produced. If you have a setClassUnion and some other functions or method definitions you need to put the setClassUnion at the beginning, but if you do that the package will build and produce the correct documentation.

#' @title S4 Class Union that roxgygen 2 does not like
#' 
#' @description This is an example that will cause an error with roxygen2 package build. The error is "Missing name at NumericList.R:7"
#'  
#' @exportClass NumericList
#' 
setClassUnion(name="NumericList", members=c("numeric","list"))

@hadley
Copy link
Member

hadley commented Sep 21, 2016

That now works fine for me (and you can use @export instead of @exportClass)

@johnpauls
Copy link
Author

Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants