Reputation: 11
I just have a data file with one column of time series:
'2012-02-01 17:42:44'
'2012-02-01 17:42:44'
'2012-02-01 17:42:44'
data.frame(table(cut(MyDates, breaks = c("week", "hours")))
After converting the the column to as.POSIXct , i'm trying to create a frequency table by weeks and hours of a day
This code does not work.
Please suggest?
Upvotes: 1
Views: 288
Reputation: 2541
The right argument to use is breaks = "hour"
(check ?cut.POSIXt
)
MyDates<-read.table(text= "2012-02-01 17:42:44
2012-02-01 17:42:44
2012-02-01 17:42:44",
header = F, sep = "_",
col.names = "date")
# convet to class POSIXct
MyDates <- as.POSIXct(MyDates$date)
# your frequency tables
hours <- table(cut(MyDates, breaks = "hour"))
weeks <- table(cut(MyDates, breaks = "week"))
Upvotes: 2