How to coerce a list object to type ‘double’

If you want to convert all elements of a to a single numeric vector and length(a) is greater than 1 (OK, even if it is of length 1), you could unlist the object first and then convert.

as.numeric(unlist(a))
# [1]  10  38  66 101 129 185 283 374

Bear in mind that there aren’t any quality controls here. Also, X$Days a mighty odd name.

Leave a Comment