Re: [R] Assignments inside lapply

2011-04-27 Thread lcn
unlist(lapply(1:nrow(ij),function(rowId) { return (Powermap[i,j]-Pr(c(ij$i[rowId],ij$j[rowId]),c(PRX,PRY),f)) }))lapply actually catches each return value of the excuted function. here your function actually returns nothing if the assignment succeeds. If your purpose for the call to Pr is

Re: [R] Assignments inside lapply

2011-04-27 Thread Nick Sabbe
No, that does not work. You cannot do assignment within (l)apply. Nor in any other function for that matter. Nick Sabbe -- ping: nick.sa...@ugent.be link: http://biomath.ugent.be wink: A1.056, Coupure Links 653, 9000 Gent ring: 09/264.59.36 -- Do Not Disapprove -Original Message-

Re: [R] Assignments inside lapply

2011-04-27 Thread Kenn Konstabel
On Wed, Apr 27, 2011 at 12:58 PM, Nick Sabbe nick.sa...@ugent.be wrote: No, that does not work. You cannot do assignment within (l)apply. Nor in any other function for that matter. Yes that may work if you want to. You can do non-local assignment within lapply using - (and, for that matter,

Re: [R] Assignments inside lapply

2011-04-27 Thread ONKELINX, Thierry
Dear Alex, I think you want to use apply() ij - expand.grid(i = seq_len(dimx),j = seq_len(dimy)) Powermap - apply(ij, 1, function(x){ Pr(x, c(PRX, PRY), f) }) Best regards, Thierry ir. Thierry Onkelinx

Re: [R] Assignments inside lapply

2011-04-27 Thread Alaios
try this out? Best Regards Alex --- On Wed, 4/27/11, ONKELINX, Thierry thierry.onkel...@inbo.be wrote: From: ONKELINX, Thierry thierry.onkel...@inbo.be Subject: RE: [R] Assignments inside lapply To: Alaios ala...@yahoo.com, R-help@r-project.org R-help@r-project.org Date: Wednesday, April 27

Re: [R] Assignments inside lapply

2011-04-27 Thread ONKELINX, Thierry
that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: Alaios [mailto:ala...@yahoo.com] Verzonden: woensdag 27 april 2011 12:14 Aan: R-help@r-project.org; ONKELINX, Thierry Onderwerp: RE: [R] Assignments inside lapply I would like to use

Re: [R] Assignments inside lapply

2011-04-27 Thread Thomas Lumley
On Wed, Apr 27, 2011 at 10:12 PM, Kenn Konstabel lebats...@gmail.com wrote: On Wed, Apr 27, 2011 at 12:58 PM, Nick Sabbe nick.sa...@ugent.be wrote: No, that does not work. You cannot do assignment within (l)apply. Nor in any other function for that matter. Yes that may work if you want to.