Re: [R] parSapply can't find function

2013-04-29 Thread Kaiyin Zhong (Victor Chung)
Sorry, I got some new error: Error in cut.default(i, breaks) : 'breaks' are not unique >>>traceback() 20: stop("'breaks' are not unique") 19: cut.default(i, breaks) 18: cut(i, breaks) 17: split.default(i, cut(i, breaks)) 16: split(i, cut(i, breaks)) 15: structure(split(i, cut(i, breaks)), names =

Re: [R] parSapply can't find function

2013-04-29 Thread Duncan Murdoch
On 29/04/2013 2:16 PM, Kaiyin Zhong (Victor Chung) wrote: Hi, Uwe. I still don't get how this can be done correctly. Here is what I tried. In the file funcs.R, define these functions: library('modeest') x = vector(length=500) x = sapply(x, function(i) i=sample(c(1,0), 1)) pastK = function(n, x

Re: [R] parSapply can't find function

2013-04-29 Thread Kaiyin Zhong (Victor Chung)
Oh, indeed, that IS the problem. Thank you!!! Best regards, Kaiyin ZHONG -- FMB, Erasmus MC k.zh...@erasmusmc.nl kindlych...@gmail.com On Mon, Apr 29, 2013 at 8:22 PM, David Winsemius wrote: > > On Apr 29, 2013, at 11:16 AM, Kaiyin Zhong (Victor Chung) wrote: > > >

Re: [R] parSapply can't find function

2013-04-29 Thread David Winsemius
On Apr 29, 2013, at 11:16 AM, Kaiyin Zhong (Victor Chung) wrote: > Hi, Uwe. > > I still don't get how this can be done correctly. Here is what I tried. > > In the file funcs.R, define these functions: > > library('modeest') > x = vector(length=500) > x = sapply(x, function(i) i=sample(c(1,0),

Re: [R] parSapply can't find function

2013-04-29 Thread Kaiyin Zhong (Victor Chung)
Hi, Uwe. I still don't get how this can be done correctly. Here is what I tried. In the file funcs.R, define these functions: library('modeest') x = vector(length=500) x = sapply(x, function(i) i=sample(c(1,0), 1)) pastK = function(n, x, k) { if (n>k) { return(x[(n-k):(n-1)]) } else {ret

Re: [R] parSapply can't find function

2013-04-23 Thread Uwe Ligges
On 23.04.2013 15:00, Kaiyin Zhong (Victor Chung) wrote: Thanks for the reply. How can i make the functions known to all nodes? See ?clusterEvalQ you may also want to try the parallel packages. Best, Uwe Ligges Best regards, Kaiyin ZHONG ---

Re: [R] parSapply can't find function

2013-04-23 Thread Kaiyin Zhong (Victor Chung)
Thanks for the reply. How can i make the functions known to all nodes? Best regards, Kaiyin ZHONG -- FMB, Erasmus MC k.zh...@erasmusmc.nl kindlych...@gmail.com On Tue, Apr 23, 2013 at 2:43 PM, Uwe Ligges wrote: > > > On 18.04.2013 11:11, Kaiyin Zhong (Victor Chun

Re: [R] parSapply can't find function

2013-04-23 Thread Uwe Ligges
On 18.04.2013 11:11, Kaiyin Zhong (Victor Chung) wrote: Here is the code, assuming 8 cores in the cpu. library('modeest') library('snow') cl = makeCluster(rep('localhost', 8), 'SOCK') x = vector(length=50) x = sapply(x, function(i) i=sample(c(1,0), 1)) pastK = function(n, x, k) { if (n>

[R] parSapply can't find function

2013-04-18 Thread Kaiyin Zhong (Victor Chung)
Here is the code, assuming 8 cores in the cpu. library('modeest') library('snow') cl = makeCluster(rep('localhost', 8), 'SOCK') x = vector(length=50) x = sapply(x, function(i) i=sample(c(1,0), 1)) pastK = function(n, x, k) { if (n>k) { return(x[(n-k):(n-1)]) } else {return(NA)} } predR