[R] subset a data.frame

Simone Gabbriellini simone.gabbriellini at gmail.com
Tue Nov 2 16:53:44 CET 2010


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")]

thanks in advance for any help.

best regards,
Simone Gabbriellini


More information about the R-help mailing list