Re: [R] Mclapply and print statement

From: Steve Lianoglou <mailinglist.honeypot_at_gmail.com>
Date: Mon, 11 Apr 2011 13:13:00 -0400

Hi,

On Mon, Apr 11, 2011 at 5:26 AM, Alaios <alaios_at_yahoo.com> wrote:
> Dear all.
> I am using the mclapply function to split my code to the many cores my system has. It seems that is working fine. This is the parallel version of lcapply.
>
> The only problem that I seem to have is that the printf cannot print messages.
>
> The ideal to me is to have fro my function an output of the form
> Shadowlist<-mclapply(1:dimz, function(i) {
>                              print(sprintf('Creating the %d map',i));
>                              GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha))
>                            }
>            )
>
> 'I am the processor %d and I work with the task %d',processorid,i
>
> So far I get not output from my print(sprintf(... function.
>
> What do you think I should try out?

Use `cat`:

R> x <- mclapply(1:20, function(i) cat(i, "\n")) 1
9
17
2
10
18
3
11
19
4
12
20
5
13
6
14
7
15
8
16

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 11 Apr 2011 - 17:15:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 11 Apr 2011 - 17:50:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive