Re: [R] Data Manipulation, add frequency index

2008-11-08 Thread Gabor Grothendieck
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

Re: [R] Data Manipulation, add frequency index

2008-11-08 Thread Dimitris Rizopoulos
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

[R] Data Manipulation, add frequency index

2008-11-08 Thread jie feng
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