Re: [R] indexing in data frames

2012-08-10 Thread peter dalgaard
ware > wdunlap tibco.com > > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On >> Behalf >> Of R. Michael Weylandt >> Sent: Thursday, August 09, 2012 4:22 PM >> To: arun >> Cc: R help;

Re: [R] indexing in data frames

2012-08-09 Thread William Dunlap
tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of R. Michael Weylandt > Sent: Thursday, August 09, 2012 4:22 PM > To: arun > Cc: R help; jimi adams > Subject: Re: [R] indexing in data frames >

Re: [R] indexing in data frames

2012-08-09 Thread R. Michael Weylandt
On Thu, Aug 9, 2012 at 5:30 PM, arun wrote: > > lapply(1:length(a$c),function(x) a$b[x]-a$c[[x]]) Arun, I've seen you use this idiom a few times lately and I'd just like to note that seq_along() is an (underutilized) primitive and a safer and faster alternative (avoiding the pathological leng

Re: [R] indexing in data frames

2012-08-09 Thread arun
ab <- data.frame(ab, diff=ab$year-ab$d) >> new <- split(ab$diff, ab$group) >> new > $G1988 > [1] 3 6 4 > > $G1989 > [1] 1 9 > > -- > David L Carlson > Associate Professor of Anthropology > Texas A&M Univer

Re: [R] indexing in data frames

2012-08-09 Thread jimi adams
- > From: jimi adams > To: r-help@r-project.org > Cc: > Sent: Thursday, August 9, 2012 4:42 PM > Subject: [R] indexing in data frames > > I'm still not fully understanding exactly how R is handling data frames, but > am getting closer. Any help with this one will likel

Re: [R] indexing in data frames

2012-08-09 Thread arun
HI, In the reply I sent, I forgot to add, anew<-list()#before, for(i in 1:length(b1)){  anew[[i]]<-list()  anew[[i]]<-b1[[i]]-c[[i]]  } A.K. - Original Message - From: jimi adams To: r-help@r-project.org Cc: Sent: Thursday, August 9, 2012 4:42 PM Subject: [R] indexing in da

Re: [R] indexing in data frames

2012-08-09 Thread arun
-2 -6 A.K. - Original Message - From: jimi adams To: r-help@r-project.org Cc: Sent: Thursday, August 9, 2012 4:42 PM Subject: [R] indexing in data frames I'm still not fully understanding exactly how R is handling data frames, but am getting closer. Any help with this one will likely

Re: [R] indexing in data frames

2012-08-09 Thread arun
ge - From: jimi adams To: arun Cc: R help Sent: Thursday, August 9, 2012 5:42 PM Subject: Re: [R] indexing in data frames Thanks. Yes, I got it to work with loops for small data. I was just hoping, given the size of the data.frame (hundreds of thousands) and the length of the lists (varying

Re: [R] indexing in data frames

2012-08-09 Thread David L Carlson
> -Original Message- > From: David Winsemius [mailto:dwinsem...@comcast.net] > Sent: Thursday, August 09, 2012 5:17 PM > To: dcarl...@tamu.edu > Cc: 'jimi adams'; r-help@r-project.org > Subject: Re: [R] indexing in data frames > > > On Aug 9, 2012, at 2:43 PM, D

Re: [R] indexing in data frames

2012-08-09 Thread David Winsemius
$year-ab$d) new <- split(ab$diff, ab$group) new $G1988 [1] 3 6 4 $G1989 [1] 1 9 -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project

Re: [R] indexing in data frames

2012-08-09 Thread David L Carlson
; project.org] On Behalf Of jimi adams > Sent: Thursday, August 09, 2012 3:43 PM > To: r-help@r-project.org > Subject: [R] indexing in data frames > > I'm still not fully understanding exactly how R is handling data > frames, but am getting closer. Any help with this one will li

[R] indexing in data frames

2012-08-09 Thread jimi adams
I'm still not fully understanding exactly how R is handling data frames, but am getting closer. Any help with this one will likely go a long way in getting me there. Let's say I have a data frame, let's call it "a". Within that data frame i have two variables, let's call them "b" and "c", where