Solution :
If you are trying to convert all elements of a to the single numeric vector and the length(a) is greater than 1 it is OK even if it is of length 1, you can unlist the object first after that convert.
as.numeric(unlist(a))
# [1] 10 38 66 101 129 185 283 374
Remember that there are many quality controls here. Also, X$Days a mighty unique name.
OR
You can see the problems with some data as follows :
as.double(as.character("2.e")) # This results in 2
Another approach as follows:
get_numbers <- function(X) {
X[toupper(X) != tolower(X)] <- NA
return(as.double(as.character(X)))
}
OR
In your case the loop will also do the job as follows :
a <- array(0, dim=dim(X))
for (i in 1:ncol(X)) {a[,i] <- X[,i]}