Re: [R] I need help for creating a "timevar"

2011-07-05 Thread kbr
Hi Josh, It works perfectly! Thanks a lot for your quick and helpful answer! Karen -- View this message in context: http://r.789695.n4.nabble.com/I-need-help-for-creating-a-timevar-tp3643658p3645575.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] I need help for creating a "timevar"

2011-07-04 Thread Joshua Wiley
Hi Karen, As long as your IDENTITY column goes up in order, this should work: ## example data dat <- data.frame(IDENTITY = rep(101:103, 3:1), EVENT = "Event") dat$TIMEVAR <- unlist(with(dat, tapply(EVENT, IDENTITY, seq_along))) ## Result dat See ?tapply and ?seq_along for some documentation Hop

[R] I need help for creating a "timevar"

2011-07-04 Thread kbr
Hi all! I have data in „Long“ format which I would like to reshape to „Wide“. I know that one possibility is the „reshape“ command, which needs a „timevar“. Data look as follows: There are approx. 3000 persons („IDENTITY“) and, for each person, there are between 2 and 20 events („EVENT“). For no