p_connolly at slingshot.co.nz
2009-Nov-10 02:28 UTC
[R] When is a function call an expression? (multicore package)
I'm trying to understand how to use the multicore package. In particular, I'm trying to work out what is covered where it says this in the help file for the parallel function: expr: expression to evaluate (do _not_ use any on-screen devices or GUI elements in this code) Can a function that produces an EPS file be considered an "expression" in this case? I've tried to run two similar functions in parallel but I'm obviously not using the term "expression" the way it's intended. I've made a trivial dummy function: dummy <- function() { require(multicore) aa <- function() { postscript(file = "AA.eps", height = 220/25.4, width = 220/25.4, paper = "special", pointsize = 15) plot(1:10) dev.off() } bb <- function() { postscript(file = "BB.eps", height = 220/25.4, width = 220/25.4, paper = "special", pointsize = 15) plot(11:20) dev.off() } aaa <- mcparallel(aa()) bbb <- mcparallel(bb()) } The AA.eps file is created, but nothing else. If I try a more elaborate function, I get even less. I tried using collect() after the two calls to mcparallel which gave this puzzling message: Error in !wait : invalid argument type> Xlib: unexpected async reply (sequence 0x80)!Am I trying to do something multicore wasn't designed to do, or am I just going about it the wrong way? ******************************************> sessionInfo()R version 2.10.0 (2009-10-26) i686-pc-linux-gnu locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] splines grDevices utils stats graphics methods base other attached packages: [1] multicore_0.1-3 gbm_1.6-3 survival_2.35-7 lattice_0.17-26 loaded via a namespace (and not attached): [1] grid_2.10.0 plyr_0.1.9 tools_2.10.0>******************************************************* TIA Patrick www.slingshot.co.nz/mobile