I am fairly new to R so excuse my baby steps in plotly. I am trying to compute density curves for total time spent
# Compute density curves
d.Bardoc <- AeDec %>%
filter(Bardoc == 1) %>%
density(AeDec$TotalTimeinAE) ##, na.rm = TRUE)
But I keep getting the following error:
Error in density.default(., AeDec$TotalTimeinAE) :
argument 'x' must be numeric
I've checked that TotalTimeinAE is numeric with str(AeDec)
:
$ TotalTimeinAE: num 315 94 470 29 17 9 11 101 23 107 ...
What do I need to do to be able to calculate density curve for this variable?
A couple of options:
1. Try taking density
out of pipe:
f.AeDec <- AeDec %>%
filter(Bardoc == 1)
d.Bardoc <- density(f.AeDec$TotalTimeinAE)
2. Try selecting your variable and unlist
before piping:
d.Bardoc <- AeDec %>%
filter(Bardoc == 1) %>%
select(TotalTimeinAE) %>%
unlist %>%
density(.)
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.