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

Can't coerce to transaction using as (df, "transactions") when executed with Rscript #20

Closed
nirsisense opened this issue Oct 28, 2016 · 5 comments
Labels

Comments

@nirsisense
Copy link

Hi,
I'm trying to run the following script:
data <- list(
c("a","b","c"),
c("a","b"),
c("a","b","d"),
c("b","e"),
c("b","c","e"),
c("a","d","e"),
c("a","c"),
c("a","b","d"),
c("c","e"),
c("a","b","d","e")
)
as(data, "transactions")

through command line Rscript and get an error:
Error: could not find function "as"
Execution halted

@vrodriguezf
Copy link

vrodriguezf commented Oct 28, 2016

Ensure that the dependencies of the arules package are loaded. as is a function from the package "methods"

@nirsisense
Copy link
Author

What are the dependent package I need to load?
I tried load "methods"
library("arules")
library("methods")
data <- list(
c("a","b","c"),
c("a","b"),
c("a","b","d"),
c("b","e"),
c("b","c","e"),
c("a","d","e"),
c("a","c"),
c("a","b","d"),
c("c","e"),
c("a","b","d","e")
)
trans <- as(data, "transactions")
still fails in Rscript but runs fine in RStudio

@vrodriguezf
Copy link

vrodriguezf commented Oct 28, 2016

Hmmmm the same lines of code are working for me, both in RStudio and RScript, event without loading "methods" explicitly...Do you have any other possible packages in the environment that could overwrite the definition of the as function ? Executing ?as in the command line gives you any result?

What OS and R version are you using?

Also, try to reinstall the package with install.packages("arules", dependencies=T)

@mhahsler
Copy link
Owner

@nirsisense is correct. This has nothing to do with arules. You need to explicitly load methods when you use Rscript.

@nirsisense
Copy link
Author

ok, thanks. It works now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants