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
>
> 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
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
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
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
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))
> #
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
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
8 matches
Mail list logo