Home > front end >  Error when creating histogram of data that is of class times in R
Error when creating histogram of data that is of class times in R

Time:11-04

Suppose I have the following data (hours,minutes,seconds)

z <- as.times(c("00:07:26","00:10:26","01:07:00"))

And I would like to create a histogram where I label the x-axis

hist(z, xlab = "Time")

I then get the following error: Warning: argument ‘xlab’ is not made use of

I do not know why this appears and I am unable to resolve it

CodePudding user response:

As @MrFlick commented, I couldn't find the source for the as.times function you are using. Using hms() from the lubridate package instead your plot function works as expected:

z <- lubridate::hms(c("00:07:26","00:10:26","01:07:00"))
hist(z, xlab = "Time")

Created on 2022-11-03 with reprex v2.0.2

  • Related