Skip to content

Function not found, maybe respective package has to be put in environment?

2 messages · Andreas Klein, Uwe Ligges

#
Hello everybody,

I have a problem and would like to start with an example:

library(snow)
library(tseries)
fn <- function(x) adf.test(x)

clusterApply(cl=cl, x=x , fun=fn)


R cannot find the function adf.test() because it is inside the function fn(). This problem does not occur when, for example, fn <- function(x) mean(x) holds. Therefore, I think the package tseries has to be put somehow in the environment where also the package stats is because the function mean() works but the function adf.test() not.

But how to solve the problem?

Remark:
The above code is an example to illustrate my problem. My original function is more complex and somewhere inside my function I refer to some other function from the package tsDyn.


I hope you can help me.

Kind regards,
Andy.
#
You have to load tseries on the nodes, not only on the master, i.e.:

clusterEvalQ(cl, library("tseries"))

Best,
Uwe Ligges
On 13.11.2011 19:34, Andreas Klein wrote: