I have a data.frame with only one column in R. I get it with an SQL query from a database. In that database that column has TIMESTAMP as datatype. In R the data.frame has datatype "double"
typeof(MyTable$TimeLogs)
[1] "double"
The data looks like this (with over 800 rows):
2016-07-19 11:24:53
2016-07-19 11:24:58
2016-07-19 11:25:03
2016-07-19 11:25:09
...
2016-07-19 19:16:05
2016-07-19 19:16:35
2016-07-19 19:17:05
2016-07-19 19:17:35
2016-07-19 19:18:06
I want a histogram that shows how often a record was made between a certain "break-time". My statement in R is:
hist(MyTable$TimeLogs, breaks = "hours",
col="red", main = "Histogramm of 2016-07-19",
xlab = "Timestamp", ylab = "Frequency")
so I can see how many timelogs were made between 11:00:00 and 12:00:00 and so on... (or maybe within 30 min breaks). My Problem now is, that the histogram looks like this:
as seen in the picture, the scale on the y-axis is quite confusing. It should go like from 2 to 50 (and not from 0.00000 to 0.00005). I guess it has something to do with the time/double-datatype of the TimeLogs. Any ideas how to put the scale right, or convert the data to the right format and still have a meaningful Y-Axis?
Just add freq=TRUE parameter to your hist call.
MyTable <- data.frame(TimeLogs=Sys.time()+round(rnorm(1000,5000,2500)))
hist(MyTable$TimeLogs, breaks = "hours",
col="red", main = "Histogramm of 2016-07-19",
xlab = "Timestamp", ylab = "Frequency",freq=TRUE)