Re: [R] Removing & generating data by category

2009-10-30 Thread Adaikalavan Ramasamy
Hmm, so if read correctly you want to remove exactly duplicated rows. So maybe try the following to begin with. duplicated(newdf[ , c("id", "loc", "clm")]) [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE Then you can remove the duplicated rows before proceedi

Re: [R] Removing & generating data by category

2009-10-29 Thread Steven Kang
> > Color me puzzled. Can you express the run more clearly in Boolean logic? > > Its a bit tedious to explain in Boolean logic.. Suppose the data is subsetted according to two distinct 'clm' variables (i.e 1 set consisting of only "General" & other only of "Life") * General.dat* * * id loc

Re: [R] Removing & generating data by category

2009-10-29 Thread David Winsemius
Color me puzzled. Can you express the run more clearly in Boolean logic? If someone has five policies: 3 Life and 2 General ... is he in or out? Applying the alternate strategy to that data set I get: out <- tapply( dat$clm, dat$uid, paste ,collapse=",") > > out A1.B1

Re: [R] Removing & generating data by category

2009-10-29 Thread Steven Kang
Highly appreciate for all the help. I have one more thing to resolve.. Suppose 3 additional records are binded to the previous arbitrary data set. i.e > a <- data.frame(id=c(c("A1","A2","A3","A4","A5"),c("A3","A2","A3","A4","A5")),loc=c("B1","B2","B3","B4","B5"),clm=c(rep(("General"),6),rep("Life

Re: [R] Removing & generating data by category

2009-10-29 Thread Adaikalavan Ramasamy
Here is another way based on pasting ids as hinted below: a <- data.frame(id=c(c("A1","A2","A3","A4","A5"), c("A3","A2","A3","A4","A5")), loc=c("B1","B2","B3","B4","B5"), clm=c(rep(("General"),6),rep("Life",4))) a$uid <- paste(a$id, ".", a

Re: [R] Removing & generating data by category

2009-10-28 Thread jim holtman
Here is one way of doing it: > a <- + data.frame(id=c(c("A1","A2","A3","A4","A5"), + c("A3","A2","A3","A4","A5")),loc=c("B1","B2","B3","B4","B5"), + clm=c(rep(("General"),6),rep("Life",4))) > # split the indices based on 'id' & 'loc' > a.indx <- split(seq(nrow(a)), paste(a$id, a$loc)) > #

Re: [R] Removing & generating data by category

2009-10-28 Thread David Winsemius
On Oct 28, 2009, at 9:30 PM, Steven Kang wrote: Dear R users, Basically, from the following arbitrary data set: a <- data .frame (id = c (c ("A1 ","A2 ","A3 ","A4 ","A5 "),c ("A3 ","A2 ","A3 ","A4","A5")),loc=c("B1","B2","B3","B4","B5"),clm=c(rep(("General"), 6),rep("Life",4))) a id

[R] Removing & generating data by category

2009-10-28 Thread Steven Kang
Dear R users, Basically, from the following arbitrary data set: a <- data.frame(id=c(c("A1","A2","A3","A4","A5"),c("A3","A2","A3","A4","A5")),loc=c("B1","B2","B3","B4","B5"),clm=c(rep(("General"),6),rep("Life",4))) > a id loc clm 1 A1 B1 General 2 A2 B2 General 3 A3 B3 General 4 A