My dataset class has "time" feature. This feature belongs to character class. I try to show the frequency of pick up per different time slot.For this reason, I used "cut" function as below:
FreqPickupTime <- cut(dt$time, breaks = "hour")
But, I occur with the below error.
Error in cut.default(dt$time, breaks = "hour") :'x' must be numeric.
is there any solution to use this cut function for character features.
As MrFlick says, cut() won't cut it for characters.
Say df$time looks something like: 16:42, 12:32, 03:20...
For example:
time <- paste0(round(runif(1000, 0, 23), digits = 0), ':', round(runif(1000, 1, 59), digits = 0))
You could simply do:
table(substr(time, 1, regexpr(':', time)-1))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With