[英]as.Date not converting character date to date in R
I am trying to convert a character date to date but result is somehow a double.我正在尝试将字符日期转换为日期,但结果不知何故是双倍的。
> x
[1] "2017-10-31"
> as.Date(x)
[1] "2017-10-31"
> as.Date(x) %>% typeof
[1] "double"
> as.Date(x,format="%Y-%m-%d") %>% typeof
[1] "double"
According to ?typeof
根据
?typeof
typeof determines the (R internal) type or storage mode of any object
typeof 确定任何 object 的(R 内部)类型或存储模式
Instead of typeof
, check the class
而不是
typeof
,检查class
library(magrittr)
as.Date(x) %>%
class
# [1] "Date"
Also, can be checked with inherits
此外,可以通过
inherits
检查
as.Date(x) %>%
inherits('Date')
#[1] TRUE
x <- "2017-10-31"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.