[R] How to group data by day
Michela Ferron
ferron at fbk.eu
Mon Feb 14 18:08:38 CET 2011
Hi everybody,
I'm a beginner in R and I'm having a hard time grouping my data by day.
The data are in this format:
id; words
2005-07-07T09:59:56Z; 35
2005-07-07T10:01:39Z; 13
2005-07-08T10:02:22Z; 1
2005-07-09T10:03:16Z; 23
2005-07-10T10:04:23Z; 39
2005-07-10T10:04:39Z; 15
I've transformed the date strings in dates with the function:
london$id <- transform(london$id, as.Date(london$id, format="%Y-%m-%d%T%H:%M:%S%Z"))
and it seems to work.
Now I would like to add a new "day" variable to group data by day, like this:
id; words; day
2005-07-07T09:59:56Z; 35; 1
2005-07-07T10:01:39Z; 13; 1
2005-07-08T10:02:22Z; 1; 2
2005-07-09T10:03:16Z; 23; 3
2005-07-10T10:04:23Z; 39; 4
2005-07-10T10:04:39Z; 15; 4
How can I do that?
Many thanks!
Michela
More information about the R-help
mailing list