[Rd] Parallel computing: how to transmit multiple parameters to a function in parLapply?

2013-12-24 Thread Yu Wan
Hi R-developers In the package Parallel, the function parLapply(cl, x, f) seems to allow transmission of only one parameter (x) to the function f. Hence in order to compute f(x, y) parallelly, I had to define f(x, y) as f(x) and tried to access y within the function, whereas y was defined outside

Re: [Rd] Parallel computing: how to transmit multiple parameters to a function in parLapply?

2013-12-24 Thread alexios ghalanos
This works: clusterExport(cl, c("f","y"), envir=environment()) r <- parLapply(cl, x, function(x) f(x,y)) You need to export your function (“f”) and additional variables (“y”), and then define that function inside parLapply ("f(x,y)”). If you were to also make use of additional libraries (or sou

Re: [Rd] Parallel computing: how to transmit multiple parameters to a function in parLapply?

2013-12-24 Thread William Dunlap
You can put the function of interest and any global variables it needs into a private environment, which gets sent along with the function to the child processes. E.g. library(parallel) cl3 <- makeCluster(3) y <- c(1,100,1) addY <- function(x) x + y withGlobals <- function(FUN, ...){ envi

[Rd] Object type name and class name

2013-12-24 Thread Fg Nu
I came across the distinction between the name of an object and the name of the class that it belongs to in an oblique way again today, which made me question my acceptance that it would be natural for them to differ. I asked a question on SO here: http://stackoverflow.com/questions/20762559/

Re: [Rd] Object type name and class name

2013-12-24 Thread Gabriel Becker
Fg, This is not really an r-devel question. It is more appropriate for r-help as far as I know. Please ask questions like it there in the future. Anyway, my understanding is that the type of an object has to do with how it is stored internally, whereas the class has to do with how it is dispatche

Re: [Rd] Object type name and class name

2013-12-24 Thread Fg Nu
Gabriel, [I understand that this is not about R development, but it seemed that this was a question about R internals that would be better answered on the R-devel list.] Thanks for your answer. Yes, this is what the person who answered on SO said as well.  But my question is about terminolog

Re: [Rd] Object type name and class name

2013-12-24 Thread Gabriel Becker
It sounds like you're attempting to apply a version of object orientation (objects being instances of classes) which does not apply to R (in the S3 world anyway). That simply isn't how S3 classes work (in many ways S3 classes aren't really "classes" at all in the way you seem to be using the word,

Re: [Rd] Object type name and class name

2013-12-24 Thread Fg Nu
Gabriel, Thanks. Not trying to influence any changes, just trying to understand better what is going on when the term "object type" is used. From what you and the SO answer seem to suggest, it has little to do with OOP/classes at all. This would be fine if John Chambers weren't explicitly jux

Re: [Rd] Object type name and class name

2013-12-24 Thread Fg Nu
[Resending because HTML was scrubbed.] Gabriel, Thanks. Not trying to influence any changes, just trying to understand better what is going on when the term "object type" is used. From what you and the SO answer seem to suggest, it has little to do with OOP/classes at all. This would be fi