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

Andreas Klein klein82517 at yahoo.de
Sun Nov 13 19:34:12 CET 2011

Hello everybody,

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

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?

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,

More information about the R-help mailing list