Re: [R] How to delete rows based on replicate values in one column with some extra calcuation

2010-06-29 Thread Yi
Great help. It works when the first and the second columns are ordered the same way. But aggregate does not work for the following case: z=c('ab','ah','bc','ah','dv') x=substr(z,start=1,stop=1) y=substr(z,start=2,stop=2) v1=5:9 v2=7:11 data=data.frame(x,y,z,v1,v2) data x y z v1 v2 1 a b ab 5

Re: [R] How to delete rows based on replicate values in one column with some extra calcuation

2010-06-29 Thread Nikhil Kaza
You can do this in reshape package as mentioned earlier. However, if you need a solution with aggregate here it is a - with(data, aggregate(cbind(v1,v2), by=list(x,y,z),sum)) names (a) - c(x,y,z,v1,v2) Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina

[R] How to delete rows based on replicate values in one column with some extra calcuation

2010-06-28 Thread Yi
Hi, folks, Please let me address the problem by the following codes: first=c('u','b','e','k','j','c','u','f','c','e') second=c('usa','Brazil','England','Korea','Japan','China','usa','France','China','England') third=1:10 data=data.frame(first,second,third) ## You may understand values in the

Re: [R] How to delete rows based on replicate values in one column with some extra calcuation

2010-06-28 Thread Nikhil Kaza
aggregate(data$third, by=list(data$first), sum) or reqiure(reshape) cast(melt(data), ~first, sum) On Jun 28, 2010, at 9:30 PM, Yi wrote: first=c('u','b','e','k','j','c','u','f','c','e') second = c ('usa ','Brazil ','England','Korea','Japan','China','usa','France','China','England')

Re: [R] How to delete rows based on replicate values in one column with some extra calcuation

2010-06-28 Thread David Winsemius
On Jun 28, 2010, at 9:30 PM, Yi wrote: Hi, folks, Please let me address the problem by the following codes: first=c('u','b','e','k','j','c','u','f','c','e') second = c ('usa ','Brazil ','England','Korea','Japan','China','usa','France','China','England') third=1:10