5

I am doing the R CMD check for my package using devtools::check and I encountered the same ERROR(see bellow) discussed here. I tried to do what was suggested there: I added a tag of #'@export before the #'@example in my prep.R code, and I also added export(prep) in NAMESPACE. However I still get the same error.

Does anyone knows how can I solve this?

Any help will be greatly appreciated

Ayala

* checking R/sysdata.rda ... OK
* checking examples ... ERROR
Running examples in 'prepdat-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: prep
> ### Title: Aggregate Long Format Data According to Grouping Variables and
> ###   Generate a Number of Measures for Each Cell in the Aggregated Data
> ###   for Further Analysis
> ### Aliases: prep
> 
> ### ** Examples
> 
> data(stroopdata)
> x1 <- prep(
+          dataset = stroopdata
+          , file_name = NULL
+          , id = "subject"
Community
  • 1
  • 1
ayalaall
  • 145
  • 2
  • 16
  • Do you have a GitHub repository for your package? – nrussell Aug 20 '15 at 12:34
  • Okay because while it's not necessarily required, it would certainly make it easier for others to figure out what the problem is, so it may be worthwhile for you to do this. – nrussell Aug 20 '15 at 12:45
  • @nrussell I plan to do so after finishing with the `R CMD` check – ayalaall Aug 20 '15 at 12:52
  • I had this error now multiple times in some of my packages. I feel like it is random. Sometimes the checks work (using devtools), sometimes they don't (from the cli). Would be great, if someone could figure this out, since Bioconductor wants examples. –  Nov 09 '17 at 20:46
  • I also encountered the same error. From the R console, the error did not occur. I also bothered the error. What should I do ??? – Camford Oxbridge Mar 15 '19 at 10:43
  • @CamfordOxbridge did you try to do the what was suggested in the answer below? Also, you can check my GitHub to see what I did. https://github.com/ayalaallon/prepdat – ayalaall Mar 16 '19 at 11:18

1 Answers1

4

I found this question when googling this exact error. I think I understand now why it occurred: Roxygen actually executes the code in the @examples section, and my code included undeclared objects and gave this exact error when running check.

Quick solution: remove the offending lines of code from the @examples section. Or, a more considerate solution is to enclose the example code within \dontrun{...}.

See ?examples for more details on this as well as other options.

solarchemist
  • 438
  • 3
  • 13