How to coerce a list object to type 'double'

前端 未结 5 627
执笔经年
执笔经年 2020-12-02 06:13

The code:

a <- structure(list(`X$Days` = c(\"10\", \"38\", \"66\", \"101\", \"129\", \"185\", \"283\", 
                                 \"374\")), .Names         


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-02 07:10

    There are problems with some data. Consider:

    as.double(as.character("2.e")) # This results in 2
    

    Another solution:

    get_numbers <- function(X) {
        X[toupper(X) != tolower(X)] <- NA
        return(as.double(as.character(X)))
    }
    

提交回复
热议问题