[R] Create a list object in a loop

2012-03-09 Thread Aurelie Cosandey Godin
Dear all, I'm trying to create a list of point patterns ppp.object {spatstat} in a loop. My dataset looks like this: names(OT1);head(OT1);dim(OT1) [1] EID latitude longitude month year CPUE TSUM [8] fTSUM EID latitude longitude

Re: [R] Create a list object in a loop

2012-03-09 Thread Tal Galili
Hi Aurelie, Please give this a look: http://www.nealgroothuis.name/introduction-to-data-types-and-objects-in-r/ And see if this resolves most, or all, of your questions... Contact Details:--- Contact me: tal.gal...@gmail.com |

Re: [R] Create a list object in a loop

2012-03-09 Thread R. Michael Weylandt
You are overriding b at each loop iteration and consequently only keeping the last one. Perhaps b - list() for(i in sort(unique(OT1$month))){ a-OT1[OT1$month==i,] b[[i]]-ppp(a$longitude,a$latitude,marks=a$fTSUM,window=newW) plot(b[[i]],main=i) } Generally it's bad practice

Re: [R] Create a list object in a loop

2012-03-09 Thread Aurelie Cosandey Godin
Thank you Tal, useful link. Best, Aurelie On 2012-03-09, at 11:53 AM, Tal Galili wrote: Hi Aurelie, Please give this a look: http://www.nealgroothuis.name/introduction-to-data-types-and-objects-in-r/ And see if this resolves most, or all, of your questions... Contact

Re: [R] Create a list object in a loop

2012-03-09 Thread Aurelie Cosandey Godin
Thank you very much Michael! Best, Aurelie On 2012-03-09, at 11:56 AM, R. Michael Weylandt wrote: You are overriding b at each loop iteration and consequently only keeping the last one. Perhaps b - list() for(i in sort(unique(OT1$month))){ a-OT1[OT1$month==i,]