Re: [R] Assignments inside lapply

2011-04-27 Thread Thomas Lumley
On Wed, Apr 27, 2011 at 10:12 PM, Kenn Konstabel wrote: > On Wed, Apr 27, 2011 at 12:58 PM, Nick Sabbe 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 assignme

Re: [R] Assignments inside lapply

2011-04-27 Thread ONKELINX, Thierry
an answer does not ensure 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 > Onde

Re: [R] Assignments inside lapply

2011-04-27 Thread Alaios
can I try this out? Best Regards Alex --- On Wed, 4/27/11, ONKELINX, Thierry wrote: > From: ONKELINX, Thierry > Subject: RE: [R] Assignments inside lapply > To: "Alaios" , "R-help@r-project.org" > Date: Wednesday, April 27, 2011, 11:06 AM > Dear Alex, >

Re: [R] Assignments inside lapply

2011-04-27 Thread ONKELINX, Thierry
2011 11:37 > Aan: R-help@r-project.org > Onderwerp: [R] Assignments inside lapply > > Dear all I would like to ask you if an assignment can be done > inside a lapply statement. > > For example > > I would like to covert a double nested for loop > > for (i in

Re: [R] Assignments inside lapply

2011-04-27 Thread Kenn Konstabel
ure Links 653, 9000 Gent > ring: 09/264.59.36 > > -- Do Not Disapprove > > > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Alaios > Sent: woensdag 27 april 2011 11:37 > To: R-help@r-project.org

Re: [R] Assignments inside lapply

2011-04-27 Thread Nick Sabbe
- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: woensdag 27 april 2011 11:37 To: R-help@r-project.org Subject: [R] Assignments inside lapply Dear all I would like to ask you if an assignment can be done inside a lapply statement. For example I would

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 jus

[R] Assignments inside lapply

2011-04-27 Thread Alaios
Dear all I would like to ask you if an assignment can be done inside a lapply statement. For example I would like to covert a double nested for loop for (i in c(1:dimx)){ for (j in c(1:dimy)){ Powermap[i,j] <- Pr(c(i,j),c(PRX,PRY),f) } } to something like that: ij<-expand.grid(i=