Re: [R] select observations from longitudinal data set

2009-01-18 Thread Gabor Grothendieck
Try this. 'by' splits up the data frame into one data frame per id and then f acts separately on each such sub-dataframe returning a ts series with NAs for the missings. cbind'ing those all together gives us this series with one column per id: > tt Time Series: Start = 1 End = 6 Frequency = 1

Re: [R] select observations from longitudinal data set

2009-01-18 Thread Dimitris Rizopoulos
one way is the following: dat <- read.table(textConnection("id time y 1 1 10 1 2 12 1 3 15 1 6 18 2 1 8 2 3 9 2 4 11 2 5 12 3 1 8 3 4 16 4 1 9 4 5 13 5 1 7 5 2 9 5 6 11"), header = TRUE) closeAllConnections() val <- 4 dat. <- data.frame(id = unique(dat$id), time = val) out <- merge(dat, dat., al

[R] select observations from longitudinal data set

2009-01-17 Thread gallon li
I have the following longitudinal data: id time y 1 1 10 1 2 12 1 3 15 1 6 18 2 1 8 2 3 9 2 4 11 2 5 12 3 1 8 3 4 16 4 1 9 4 5 13 5 1 7 5 2 9 5 6 11 I want to select the observations at time 4. if the observation at time 4 is missing, then i want to slect the observation at time 3. if the ob