mutate(mtest = as.yearmon(as.numeric(myear), "%y %b"))但没那么走运。谁能帮帮我。提前谢谢。
发布于 2018-08-01 06:13:13
您可以尝试:
library(zoo)
as.yearmon("2001.01", "%Y.%m")
[1] "Jan 2001"发布于 2018-08-01 06:39:43
Lubridate对日期非常有帮助。
d <- c('2001.01.01','2002.12.12')
noise <- c(1,2)
df <- cbind(d,noise)
df <- as.data.frame(df)
df$d <- ymd(df$d)
df$m <- months(as.Date(df$d))
df$y <- year(as.Date(df$d))
df <- unite(df, date, c(y,m),remove=TRUE, sep=" ")这将使您看到一个包含“month_name year”的列。我唯一不关心的就是月份的缩写名称。
https://stackoverflow.com/questions/51622628
复制相似问题