Re: [R] subsetting with by() or other function??

2005-10-13 Thread Brian S Cade
Combes [EMAIL PROTECTED] 10/13/2005 05:34 AM To Brian S Cade [EMAIL PROTECTED] cc Subject Re: [R] subsetting with by() or other function?? maybe an example of the data you have and the data you want could be helpful for the people of the list to understand, and so to be able to help you

Re: [R] subsetting with by() or other function??

2005-10-13 Thread Brian S Cade
PROTECTED] 10/13/2005 10:04 AM To Brian S Cade [EMAIL PROTECTED] cc Subject Re: [R] subsetting with by() or other function?? I think this should be something like: dat$LAG1DBC - tapply(dat$DBC, dat$LOCID, function(x) c(NA, x[-length(x)])) I hope it helps. Best, Dimitris Dimitris

[R] subsetting with by() or other function??

2005-10-12 Thread Brian S Cade
I think I must be missing something obvious, but I'm having trouble getting a data transformation to work on groupings of data within a data frame (csss3) as defined by 2 factors (population, locid). The data are sorted by year within locid within population and I want to lag another variable