I'm using the "topicmodels" package in R. Everything works fine interactively, but if I run the exact same commands using Rscript, I get errors.
The first error (which I solved) is that R didn't know what the is() function was. I solved this by importing the "methods" package. Apparently, Rscript doesn't import this automatically, even though interactive R does, and this caused a problem with is(). Problem solved.
However, I am now stuck at a different error, which I can't figure out. I am using the LDA() function in the "topicmodels" package, using data (in DTM format) and k=10. I call it like this:
library(plyr)
library(lda)
library(topicmodels)
x = as.data.frame(sapply(1:100, function(x) sample(1:100,100,replace=T)))
u = llply(colnames(x), function(a) rbind(0:(length(x[,a])-1),x[,a]))
v = rownames(x)
y = ldaformat2dtm(u, v)
a = LDA(x, 10)
And it gives me the following error:
> Error in as(control, "LDA_VEMcontrol") :
>   no method or default for coercing "NULL" to "LDA_VEMcontrol"
> Calls: LDA -> method -> as
> Execution halted
The main thing is this works interactively, but not using Rscript. I know the data is correctly formatted and if I print the data, it looks good. Is there something else I'm missing? Are there other modules that Rscript doesn't load, but R interactive does load? Thanks!