Re: [R] Assigning value of subset argument in "subset" function

2009-08-23 Thread David Winsemius
On Aug 24, 2009, at 12:24 AM, Steven Kang wrote: Hi David, I have another question regarding the R statement you have provided which is: for (zz in unique(a$xx) ) assign( paste("sub.a", zz, sep="."), sum(subset(a, xx==zz)$xxx) ) If the xx variables were characters instead of nume

Re: [R] Assigning value of subset argument in "subset" function

2009-08-23 Thread David Winsemius
On Aug 23, 2009, at 10:51 PM, Steven Kang wrote: > David, apreciate for your help. > > However, the result is not what I was expecting. > > Following on from your code, for example say the input is: > >a <- data.frame(x=rep(1:4,2), y=rep(4:7,2), xx=rep(8:11,2), > xxx=rep(12:15,1)) > >

Re: [R] Assigning value of subset argument in "subset" function

2009-08-23 Thread David Winsemius
On Aug 23, 2009, at 10:51 PM, Steven Kang wrote: David, apreciate for your help. However, the result is not what I was expecting. Following on from your code, for example say the input is: a <- data.frame(x=rep(1:4,2), y=rep(4:7,2), xx=rep(8:11,2), xxx=rep(12:15,1)) x y xx x

Re: [R] Assigning value of subset argument in "subset" function

2009-08-23 Thread Steven Kang
David, apreciate for your help. However, the result is not what I was expecting. Following on from your code, for example say the input is: a <- data.frame(x=rep(1:4,2), y=rep(4:7,2), xx=rep(8:11,2), xxx=rep(12:15,1)) x y xx xxx 1 1 4 8 12 2 2 5 9 13 3 3

Re: [R] Assigning value of subset argument in "subset" function

2009-08-23 Thread David Winsemius
On Aug 23, 2009, at 10:12 PM, David Winsemius wrote: On Aug 23, 2009, at 9:56 PM, Steven Kang wrote: Dear R users, I am using "subset" function to filter out specific conditions and would like to use the value of subsetted argument as a name of an object. Specifically, from the followin

Re: [R] Assigning value of subset argument in "subset" function

2009-08-23 Thread David Winsemius
On Aug 23, 2009, at 9:56 PM, Steven Kang wrote: Dear R users, I am using "subset" function to filter out specific conditions and would like to use the value of subsetted argument as a name of an object. Specifically, from the following statement: a <- subset(dat, dat$x == "A" & dat$xx

[R] Assigning value of subset argument in "subset" function

2009-08-23 Thread Steven Kang
Dear R users, I am using "subset" function to filter out specific conditions and would like to use the value of subsetted argument as a name of an object. Specifically, from the following statement: a <- subset(dat, dat$x == "A" & dat$xx == 1 & dat$xxx == "AB" & dat$y == "B" & dat$yy == 2)