简体   繁体   中英

Issue in Histogram Plotting in R

I'm trying to plot histogram of sample data available in lubridate package in R. The following code i'm using to create a histogram but i'm getting an error for duration which states: Incompatible duration classes (Duration, numeric). Please coerce with as.duration . Could anyone tell what is the issue here?

library("lubridate")
library("ggplot2")
str(lakers$time)
lakers$time<-ms(lakers$time)
lakers$time <- as.duration(lakers$time)
lakers$time <-dminutes(c(12, 24, 36, 48, 53)[lakers$period]) - lakers$time
qplot(time, data=lakers, geom = "histogram", binwidth = 60)

Link to Histogram Output: https://stats.stackexchange.com/questions/256779/issue-in-histogram-plotting-in-r

我使用as.numeric,并使用较旧版本的R studio将这两个类都转换为数字类

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM