See ?ave and ?seq_along
DF <- data.frame(Name = c("Mary", "Mary", "Mary", "Sam", "Sam",
"John", "John", "John", "John"), stringsAsFactors = FALSE)
DF$index <- ave(1:nrow(DF), DF$Name, FUN = seq_along)
On Sat, Nov 8, 2008 at 5:43 AM, jie feng <[EMAIL PROTECTED]> wrote:
> Hi, there,
>
> I have
one way is with ave(), e.g.,
dat <- data.frame(name = rep(c("Mary", "Sam", "John"), c(3,2,4)))
dat$freq <- ave(seq_along(dat$name), dat$name, FUN = seq_along)
dat
I hope it helps.
Best,
Dimitris
jie feng wrote:
Hi, there,
I have a simple data manipulation question for you. Thank you for yo
Hi, there,
I have a simple data manipulation question for you. Thank you for your help!
Suppose that I have this data about people appearing in a class
Mary
Mary
Mary
Sam
Sam
John
John
John
John
Then I want to find out what exact time(s) the student appears at the
moment such as
Mary 1
Mary
3 matches
Mail list logo