r - Factor as date to numeric -
i'm sorry bothering can't find solution this.
i have data.frame column name date:
str(df$date) factor w/ 360 levels "1982-11-30","1982-12-31",..: 1 4 7 10 13 16 19 22 25 28 ... class(a) [1] "factor"
i convert numeric values: from: "1982-11-30" 19821130 or else.
edit:
initially have had in numeric format , converted factor following:
date <- as.date(as.character(df$date_num),format="%y%m%d")
so how reverse this?
something this?
dd <- structure(1:2, .label = c("2013-01-01", "2013-02-01"), class = "factor") # [1] 2013-01-01 2013-02-01 # levels: 2013-01-01 2013-02-01 as.numeric(gsub("-", "", as.character(dd), fixed=true)) # [1] 20130101 20130201
Comments
Post a Comment