many thanks, works perfectly! best, Simone
Il giorno 02/nov/2010, alle ore 17.17, David Winsemius ha scritto: > > On Nov 2, 2010, at 11:53 AM, Simone Gabbriellini wrote: > >> Hello List, >> >> this should be simple, but cannot figure it out. I am trying to subset a >> data.frame like this: >> >>> data4 >> users time >> 1 user5 2009-12-01 14:09:58 >> 2 user1 2009-12-01 14:40:16 >> 3 user8 2009-12-04 08:18:37 >> 4 user6 2009-12-04 08:18:37 >> 5 user83 2009-12-04 08:18:37 >> 6 user82 2009-12-04 08:18:37 >> 7 user31 2009-12-04 08:18:37 >> 8 user85 2009-12-04 08:18:37 >> 9 user33 2009-12-04 08:18:37 >> 10 user2 2010-01-05 07:18:36 >> >> I would like to subset it and retain, let's say, only the data with time < >> '2010-01-05 07:18:36', but I have no idea about the sintax to do that. >> >> is something like this close to the correct way: >> >> active<-data4['time'<= as.POSIXct("2010-01-05 07:18:36", origin="1970-01-01 >> 00:00:00-00")] > > Close. Try: > > active <- data4[data4$time <= as.POSIXct("2010-01-05 07:18:36", > origin="1970-01-01 00:00:00-00") , ] > > Or: > > active <- subset(data4, time <= as.POSIXct("2010-01-05 07:18:36", > origin="1970-01-01 00:00:00-00") ) > >> > > > -- > > David Winsemius, MD > West Hartford, CT > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.