I am having troubles to separate large numbers into groups. For example:
a<-"2009031930111"
what I would like to get it:
year<-2009
month<-03
day<-19
Thank you in advance.
I am having troubles to separate large numbers into groups. For example:
a<-"2009031930111"
what I would like to get it:
year<-2009
month<-03
day<-19
Thank you in advance.
Using substr()
you can do:
a<-"2009031930111"
substr(a, 1, 4)
substr(a, 5, 6)
substr(a, 7, 8)
eventually you want to convert: as.numeric(substr(...))
As @Ananda Mahto said you can convert it into date object and then using lubridate
package separate its years, months and date
a<-"2009031930111"
x <- strptime(a, "%Y%m%d")
library(lubridate)
year(x)
# [1] 2009
month(x)
# [1] 3
day(x)
# [1] 19