Skip to content
Prev 307486 / 398506 Next

Qustion about Creating a sequence of vector

HI,By customising sequence(),
set.seed(1)
dat1<-data.frame(id=rep(c(1,2,3),c(30,20,25)),value=rnorm(75,15))
#Either
dat1$seq1<-unlist(sapply(table(dat1$id),FUN=function(x) 1:x),use.names=FALSE)
#or
dat1$seq1<-unlist(sapply(count(dat1$id)$freq,FUN=function(x) seq_len(x)))

#can be used.

A.K.




----- Original Message -----
From: William Dunlap <wdunlap at tibco.com>
To: bibek sharma <mbhpathak at gmail.com>; "r-help at r-project.org" <r-help at r-project.org>
Cc: 
Sent: Tuesday, October 9, 2012 3:27 PM
Subject: Re: [R] Qustion about Creating a sequence of vector
[1]? 1? 2? 3? 4? 1? 2? 1? 2? 3? 4? 5? 6? 7? 8? 9 10

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.