ot;a", "b", "c", "date"), row.names = c(NA,
-16L), class = "data.frame")
Thanks
> Date: Thu, 2 Jan 2014 08:09:59 -0800
> From: smartpink...@yahoo.com
> Subject: Re: [R] Create a unique group id
>
ames = c("a", "b", "c", "date"), row.names = c(NA,
-16L), class = "data.frame")
Thanks
> Date: Thu, 2 Jan 2014 08:09:59 -0800
> From: smartpink...@yahoo.com
> Subject: Re: [R] Create a unique group
Hi,
Also, to make it general:
vec1 <- with(dat,paste(a,b))
within(dat,d <- as.numeric(factor(vec1,labels=seq(length(unique(vec1))
#or
within(dat,d <- match(vec1,unique(vec1)))
#or
within(dat,d<- as.numeric(interaction(a,b))) #ids are unique, not in the same
order
A.K.
On Thursday, J
Hi,
Try:
dat <- read.table(text="a b c
1 1 1
1 1 1
1 1 1
1 2 2
1 2 2
1 2 2
1 3 3
1 3 3
1 3 3
2 1 4
2 1 4
2 1 4
2 2 5
2 2 5
2 2 5
2 2 5",sep="",header=TRUE)
ho
> Sent: Thursday, January 02, 2014 12:33 PM
> To: r-help@r-project.org
> Subject: [R] Create a unique group id
>
> I have a following sample data frame. How can I create a group id of
> column and b and to obtain column c? ab c 1 1 1 1
> 1
> 1
I have a following sample data frame. How can I create a group id of column and
b and to obtain column c? a b c 1 1 1 1 1 1 1
1 1 1 2 2 1 2 2 1 2 2 1 3 3 1
3 3 1 3 3 2 1 4 2 1
6 matches
Mail list logo