[R-sig-Epi] question about selecting observations
FZ
gerifalte28 at hotmail.com
Tue Jul 17 21:35:17 CEST 2007
This is not really an epi question. Also, please read the posting guide
which tells you to provide a reproducible example.
Anyhow, I think this may do what you want:
datasorted <- data[order(data$ID, data$date, decreasing=TRUE),]
firstobs<- data[!duplicated(data$Date),]
This assumes that by first observation you mean the first record for
each Date. You can easily extend this to select the first observation by ID.
I hope this helps,
Francisco
Lynn Disney wrote:
> I have a large dataset and I need to sort by ID and date, then select
> the first observation...I have seen how to do this and delete the first
> obs. Not sure how to extend the concept...
>
>
>
> Can anyone help?
>
>
>
> Lynn D. Disney, Ph.D., J.D., M.P.H.
>
> Research Analyst
>
> SEIU 1199
>
> 1771 E. 30th Street
>
> Cleveland, Ohio 44114
>
> Telephone: (216) 566-0117
>
> Email: ldisney at seiu1199.org <mailto:ldisney at seiu1199.org>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Epi at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-epi
>
>
>
>
More information about the R-sig-Epi
mailing list