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"
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.
Related
I am trying to push the following package to CRAN, but I keep getting an error on the check.
Error:
✓ checking R/sysdata.rda ...
WARNING
‘qpdf’ is needed for checks on size reduction of PDFs
✓ checking installed files from ‘inst/doc’ ...
✓ checking files in ‘vignettes’ ...
E checking examples (3s)
Running examples in ‘oRus-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: analyseStories
> ### Title: Analysing Stories
> ### Aliases: analyseStories
>
> ### ** Examples
>
> # Transform the stories
> fileUrl <- example_stories()
> stories <- analyseStories(fileUrl, 7)
Joining, by = "word"
Joining, by = "word"
Error in loadNamespace(name) : there is no package called ‘reshape2’
Calls: analyseStories ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
Current problems:
The example is in orus::analyseStores(...) function.
The example actually runs and works on the pkgdown website.
The error appears only when doing devtools::check
I have tried multiple things:
This answer base::assign(".ptime", proc.time(), pos = "CheckExEnv") ERROR when using devtools::check suggested using dontrun{...}. It passes CRAN's check, but it was bounced by a person after a couple of days.
This answer R package fails devtools::check, because "could not find function" even though the function is imported in NAMESPACE suggested doing require on the missing library. I did require(reshape2) but the check still does not pass.
This answer "Could not find function" in Roxygen examples during CMD check suggests that I need to make all my functions public (exported). I don't want to do that. I tried doing orus:::some_function(...) to call to the non-exported functions inside analyseStores but it doesn't work either.
According to this one: R package build failed when checking examples the data is working and the function has the #export tag. Also, namespace is properly updated.
I have run out of options. Any idea of what is happening?
As #stefan suggested in the comments, I had to add reshape2 into the Suggested packages in the description file. I added using:
usethis::usepackage("reshape2", "Suggests")
Followed by regenerating the docs:
devtools:document()
Package is on its way to CRAN!
I have an R package that I'm testing on travis-ci. I've tried several times to make code corrections based on the job log from the previous build. When I make the appropriate changes and push to the GitHub repo and new build is triggered but ends up halting on the same error.
checking examples ... ERROR
Running examples in ‘FARSfunctions-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: fars_summarize_years
> ### Title: Summarize fatality counts by year
> ### Aliases: fars_summarize_years
>
> ### ** Examples
>
> fars_summarize_years(2013)
Warning in value[[3L]](cond) : invalid year: 2013
Error in grouped_df_impl(data, unname(vars), drop) :
Column `year` is unknown
I have many commits hence changed the call to fars_summarize_years with the arg 2013 to 2015 and besides putting the example under \dontrun{}.
#'#examples
#'\dontrun{
#'fars_summarize_years(2015)
#'}
#'#export
#'
fars_summarize_years <- function(years) {
dat_list <- fars_read_years(years)
dt <- dplyr::bind_rows(dat_list)
grpd <- with(dt, dplyr::group_by(dt, year, MONTH))
sum_stats <- with(grpd, dplyr::summarize(grpd, n = n()))
results <- with(sum_stats, tidyr::spread(sum_stats, year, n))
knitr::kable(results, align = 'c', caption = "Fatalities by Month")
}
But it still shows up as what the build is using. Why? Shouldn't the push to GitHub resync the files?
Although the code had been updated in the package /R directory, it was part of the roxygen documentation. When the /man documentation files are created their code is taken from the roxygen docs in the main /R files. BUT the /man documentation files are not updated with each change to the roxygen in the /R files. The build on travis.ci was using the /man files to test the examples instead of from the roxygen documentation where there were originally written and saved, and where I was modifying them. The solution was to update the documentation in the /R files and then run roxygen::roxygenize which updated the /man files based on the changes made.
I am currently running an example in the glmnet documentation (https://cran.r-project.org/web/packages/glmnet/glmnet.pdf page 3):
> x=matrix(rnorm(100*20),100,20)
> y=rnorm(100)
> fit1=glmnet(x,y)
> plot(fit1,xvar="lambda")
However, I get this error message
Error in as.vector((beta %*% ones) > 0) :
no method for coercing this S4 class to a vector
and I need help to understand why the error occurs.
I run exactly the code you put and it works.
Maybe you should remove your workspace and run again the code.
According to (Mfuzz (clustering software))
http://
127.0.0.1:14087/library/utils/html/data.html
I want to create data(...) from my file which is .txt.
By using commands: read.table(), head(), summary() << the data can print out but when I use data(), the warning appears as below
> exprsFile <- "C:/Users/admin/Documents/CIP.txt"
> read.table(exprsFile)
^this is ok, my all file data print out
> data(read.table(exprsFile))
Warning message:
In data(read.table(exprsFile)) : data set ‘read.table(exprsFile)’ not found
Also,
> load(read.table(exprsFile))
Error in load(read.table(exprsFile)) : bad 'file' argument
How to fix this problem for making data()?
Thank you very much
I am not sure what you're trying to do. But can you check if this works:
data<- function(a){
d<-a
return(d)}
Then:
data(read.table(exprsFile))
I was reading this article: Visualizing Tables with plot.table. In it there is a mention of a function plota.format(). I tried running that function with my data to see the visualization. But I am getting the following error:
Error: could not find function "plota.format"*
My question is: Which package does plota.format() belong to?
Thanks!
It doesn't seem like it's an actual package, but you can get it with the following (which I borrowed from the author's github
> library(RCurl)
> sit <- getURLContent(
'https://github.com/systematicinvestor/SIT/raw/master/sit.gz',
binary = TRUE, followlocation = TRUE, ssl.verifypeer = FALSE)
> con <- gzcon(rawConnection(sit, 'rb'))
> source(con)
> close(con)
> plota.format
The source code looks like it's not formatted as source code normally is, so I'm guessing this might be the only way. If you take a look at ls() now, you'll see you've got all the functions in the package so you might want to save them.
It appears to be in the package Systematic Investor Toolbox, described in the link you posted. You can view it on GitHub here.