Hi, Given a frame with calendar date's: "2005-07-01", "2005-07-02","2005-07-03","2005-07-04","2005-07-05",etc. I want to extract the following from these dates: week number month number year number Any ideas how to accomplish this? Many thanks. Regards, Richard
This is one way to do it.> x<-c("2005-07-01", "2005-07-02","2005-07-03","2005-07-04","2005-07-05") > x[1] "2005-07-01" "2005-07-02" "2005-07-03" "2005-07-04" "2005-07-05"> substr(x,1,4)[1] "2005" "2005" "2005" "2005" "2005"> substr(x,6,7)[1] "07" "07" "07" "07" "07"> substr(x,9,10)[1] "01" "02" "03" "04" "05">======= 2005-12-12 20:06:00 伳侜佋佢伬伌佇伵佒佇佇伌伒伬仯伜======>Hi, > >Given a frame with calendar date's: > >"2005-07-01", "2005-07-02","2005-07-03","2005-07-04","2005-07-05",etc. > >I want to extract the following from these dates: > >week number >month number >year number > >Any ideas how to accomplish this? > >Many thanks. > >Regards, >Richard > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html= = = = = = = = = = = = = = = = = = = 2005-12-12 ------ Deparment of Sociology Fudan University My new mail addres is ronggui.huang at gmail.com Blog:http://sociology.yculblog.com
do.call("rbind", strsplit(as.character(date.vector), "-")) Richard van Wingerden a ??crit :>Hi, > >Given a frame with calendar date's: > >"2005-07-01", "2005-07-02","2005-07-03","2005-07-04","2005-07-05",etc. > >I want to extract the following from these dates: > >week number >month number >year number > >Any ideas how to accomplish this? > >Many thanks. > >Regards, >Richard > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > >
> x<-as.Date(c("2005-07-01", "2005-07-02","2005-07-03","2005-07-04","2005-07-05")) > weekdays(x)[1] "佇伹伷佢佄佸" "佇伹伷佢伭侚" "佇伹伷佢伻佌" "佇伹伷佢佉伝" "佇伹伷佢伓侢"> months(x)[1] "伷佭佋伮" "伷佭佋伮" "伷佭佋伮" "伷佭佋伮" "伷佭佋伮" ======= 2005-12-12 20:17:38 伳侜佋佢伬伌佇伵佒佇佇伌伒伬仯伜======>Thanks! >That solves my problem for year numbers and month numbers >Any idea how to do this for week numbers? > >Regards, >Richard > >On 12/12/05, ronggui <042045003 at fudan.edu.cn> wrote: >> This is one way to do it. >> > x<-c("2005-07-01", "2005-07-02","2005-07-03","2005-07-04","2005-07-05") >> > x >> [1] "2005-07-01" "2005-07-02" "2005-07-03" "2005-07-04" "2005-07-05" >> > substr(x,1,4) >> [1] "2005" "2005" "2005" "2005" "2005" >> > substr(x,6,7) >> [1] "07" "07" "07" "07" "07" >> > substr(x,9,10) >> [1] "01" "02" "03" "04" "05" >> > >> >> >> ======= 2005-12-12 20:06:00 伳侜佋佢伬伌佇伵佒佇佇伌伒伬仯伜======>> >> >Hi, >> > >> >Given a frame with calendar date's: >> > >> >"2005-07-01", "2005-07-02","2005-07-03","2005-07-04","2005-07-05",etc. >> > >> >I want to extract the following from these dates: >> > >> >week number >> >month number >> >year number >> > >> >Any ideas how to accomplish this? >> > >> >Many thanks. >> > >> >Regards, >> >Richard >> > >> >______________________________________________ >> >R-help at stat.math.ethz.ch mailing list >> >https://stat.ethz.ch/mailman/listinfo/r-help >> >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >> >> = = = = = = = = = = = = = = = = = = = >> >> >> >> >> >> 2005-12-12 >> >> ------ >> Deparment of Sociology >> Fudan University >> >> My new mail addres is ronggui.huang at gmail.com >> Blog:http://sociology.yculblog.com >>= = = = = = = = = = = = = = = = = = = 2005-12-12 ------ Deparment of Sociology Fudan University My new mail addres is ronggui.huang at gmail.com Blog:http://sociology.yculblog.com