Re: [R] mapply to lapply

From: Andreas Borg <andreas.borg_at_unimedizin-mainz.de>
Date: Mon, 18 Apr 2011 12:10:15 +0200

My solution would be to use an index variable that goes from 1 to the number of rows that are to be processed, along with a helper function which calls Fwithcellvalue with the suitable arguments:

F2[i+1,j+1]<-sum(lapply(1:nrow(cells), function(rowInd) Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5]))

Best regards,

Andreas

Alaios schrieb:
> Dear all,
>
> I would like to ask your help concerning
> converting a mapply function to lapply. The reason is that I would like to use
> mclapply which requires lapply syntax.
>
> The command I would like to convert is:
> F2[i+1,j+1]<-sum(mapply(Fwithcellvalue,i=i,j=j,a=cells[,2],b=cells[,4],c=cells[,1],d=cells[,3],e=cells[,5]))
>
> Could you please help me understand how I should change it?
>
>
> Best Regards
> Alex
>
> ______________________________________________
> 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.
>
>

-- 
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: borg_at_imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

______________________________________________
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 18 Apr 2011 - 10:11:15 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 18 Apr 2011 - 11:20:32 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