I am using the arules and arulesViz package in R to implement a set of association rules on my data. It worked fine till few days back. But now I am getting the below error whenever I load the R file where I used this package.
Loading required package: arules
Loading required package: Matrix
Attaching package: ‘arules’
The following objects are masked from ‘package:base’:
%in%, write
Error in length(obj) : Method length not implemented for class rules
In addition: Warning message:
package ‘arules’ was built under R version 3.1.3
Error in length(obj) : Method length not implemented for class rules
Error in length(obj) : Method length not implemented for class rules
Error in length(obj) : Method length not implemented for class rules
If I use the plot() function from arulesViz I face this below error:
Error in seq_along(x) : Method length not implemented for class rules
So tried to uninstall the package and reinstalled it. It worked only for the first time after reinstallation, it also threw the below error when I used for the first time after reinstallation.
Loading required package: arules
Loading required package: Matrix
Attaching package: ‘arules’
The following objects are masked from ‘package:base’:
%in%, write
But once I saved the file and loaded it back the old error messages repeated again. I searched in Google but nothing close to this type of error is ever posted by anyone. Your help is appreciated. Thanks.
FWIW I got this same error and this SO page is the only Google result that comes up. This fixed it for me (but I don't know why...)
> detach("package:arules", unload=TRUE)
> library("arules", lib.loc="[wherever your R libraries go]")
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 am quite new to unit testing, and I would like to implement some simple unit tests for the functions of an R package. The problem is that most functions of this R package are currently not exported, so that most of unit tests will concern R functions that are not mentioned in the NAMESPACE file.
This concerns the following R package : https://gitlab.com/f.santos/anthropmmd/tree/devel
I am using testthat, and when I try to test an R function that is not exported (for example, the most simple function in the package, max3), I get the following error message:
> setwd('............./AnthropMMD/')
> library(devtools)
> devtools::load_all()
Loading AnthropMMD
Registered S3 methods overwritten by 'ggplot2':
method from
[.quosures rlang
c.quosures rlang
print.quosures rlang
Registered S3 methods overwritten by 'car':
method from
influence.merMod lme4
cooks.distance.influence.merMod lme4
dfbeta.influence.merMod lme4
dfbetas.influence.merMod lme4
Attaching package: ‘testthat’
The following objects are masked from ‘package:devtools’:
setup, test_file
> test()
Loading AnthropMMD
Testing AnthropMMD
✔ | OK F W S | Context
✖ | 0 1 | max3
────────────────────────────────────────────────────────────────────────────────
test-max3.R:5: error: max3 gives correct answer
could not find function max3
I found on this thread that using devtools::load_all() before running the tests should fix the problem, but it did not work for me, and I guess I should have missed something.
What is the correct and complete set up one should follow to be able to test non-exported functions in an R package?
Thanks!
(NB: as I am not an Rstudio user, please do not make me any "Rstudio-specific" answer ;))
Working through a download script for CPS data found here. Using the script verbatim, per recent update, except for the Java modification that I added for my environment (below) to fix a previous error in loadnamespace. While I am familiar with the basics of R, this is my first foray into MonetDBLite.
# configure Java
if (Sys.getenv("JAVA_HOME")!="")
Sys.setenv(JAVA_HOME="")
library(rJava)
Now I am getting the following error, which generally comes after 380,000 of the 400,000 cps asec lines are processed.
Warning message:
In readLines(url) :
incomplete final line found on 'http://thedataweb.rm.census.gov/pub/cps/march/asec2015early_pubuse.dd.txt'
Error in dbConnect(MonetDBLite::MonetDBLite(), dbfolder) :
error in evaluating the argument 'drv' in selecting a method for function 'dbConnect': Error: 'MonetDBLite' is not an exported object from 'namespace:MonetDBLite'
MonetDBLite has just been updated on CRAN, please reinstall.
Sometimes when I try to load dplyr I get the following error:
Error in library.dynam(lib, package, package.lib) :
shared object ‘dplyr.so’ not found
In addition: Warning message:
S3 methods ‘[.grouped_df’, ‘[.tbl_df’, ‘all.equal.tbl_df’, ‘all.equal.tbl_dt’, ‘anti_join.data.frame’, ‘anti_join.data.table’, ‘anti_join.tbl_df’, ‘anti_join.tbl_sql’, ‘arrange_.data.frame’, ‘arrange_.data.table’, ‘arrange_.grouped_dt’, ‘arrange_.tbl_df’, ‘arrange_.tbl_dt’, ‘arrange_.tbl_sql’, ‘as.data.frame.grouped_df’, ‘as.data.frame.rowwise_df’, ‘as.data.frame.tbl_cube’, ‘as.data.frame.tbl_df’, ‘as.data.frame.tbl_dt’, ‘as.data.frame.tbl_sql’, ‘as.fun_list.character’, ‘as.fun_list.fun_list’, ‘as.tbl.data.frame’, ‘as.tbl.data.table’, ‘as.tbl.tbl’, ‘as.tbl_cube.array’, ‘as.tbl_cube.data.frame’, ‘as.tbl_cube.matrix’, ‘as.tbl_cube.table’, ‘auto_copy.tbl_cube’, ‘auto_copy.tbl_df’, ‘auto_copy.tbl_dt’, ‘auto_copy.tbl_sql’, ‘c.sql’, ‘collapse.data.frame’, ‘collapse.tbl_df’, ‘collapse.tbl_dt’, ‘collapse.tbl_sql’, ‘collect.data.frame’, ‘c [... truncated]
Error: package or namespace load failed for ‘dplyr’
Once I restart the R process is will work fine. Is there any reason this is happening sometimes but not other times?
I can't comment because I don't have 50 reputation HOWEVER I did have the same problem and I followed what marbles had suggested.
I am using a Mac and was using Microsoft's checkpoint package and could not load it properly if I had library(dplyr) in my R chunk. I removed the dplyr folder from ~/Library/R/3.3/library/dplyr as well as the dplyr folder from ~/.checkpoint/2017-01-01/lib/dplyr then just loaded the libraries and checkpoint seemed to correctly load dplyr.
I was obviously using the checkpoint date of January 1 2017. I also had to create the local .checkpoint folder because it was not automatically created. My document compiles (I haven't tried any serious code in it yet though) so I am assuming it works.
I use R version 2.15.1 (2012-06-22) and mgcv version 1.7-22
I load the following set of packages in R:
library(sqldf)
library(timeDate)
library(forecast)
library(xts)
library(tseries)
library(MASS)
library(mgcv)
It happens that I can not run a simple model (I omit the code). Even the sample code taken from the help pages:
dat = gamSim(1,n=400,dist="normal",scale=2)
b = gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
gives an error:
Error in qr.qty(qrc, sm$S[[l]]) :
NA/NaN/Inf in foreign function call (arg 5)
In addition: Warning message:
In smoothCon(split$smooth.spec[[i]], data, knots, absorb.cons, scale.penalty = scale.penalty, :
number of items to replace is not a multiple of replacement length
Note that everything works fine, if I just load the package mgcv and then use the sample code right away. It also works if I just load all the packages and run the sample code. It just does not work if I
load all packages
do some file reading, sqldf statements, ts operations and some models from package forecast.
if I then apply GAM, it does not work anymore.
Apparently the variable definitions in the general environment mess up the functioning of the package.
Are there any known issues? Are there general rules that I have to obey if I load various packages? Can I write code that "disturbed" the package mgcv?
# Richard there are 2 GAM related packages: gam and mgcv. Loading both libraries at the same time usually causes a conflict.
Loading mgcv as the first package solved my problem ... strange but true.