Cut function in R -
my dataset class has "time" feature. feature belongs character class. try show frequency of pick per different time slot.for reason, used "cut" function below:
freqpickuptime <- cut(dt$time, breaks = "hour")
but, occur below error.
error in cut.default(dt$time, breaks = "hour") :'x' must numeric.
is there solution use cut function character features.
as mrflick says, cut()
won't cut characters.
say df$time
looks 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 do:
table(substr(time, 1, regexpr(':', time)-1))
Comments
Post a Comment