Re: [R] Date formats

2012-06-20 Thread arun
"%d%b%Y") library(zoo)as.yearmon(x1) [1] "Oct 1928" "Nov 1928" "Dec 1928" "Jan 1929" A.K. - Original Message - From: arun To: "w...@dataanalyticscorp.com" Cc: R help Sent: Tuesday, June 19, 2012 7:04 PM Subject: Re: [R] Da

Re: [R] Date formats

2012-06-20 Thread arun
Hi, Try this:  str1<-c("01OCT1928","02OCT1928","03OCT1928","04OCT1928") strptime(str1,"%d%b%Y") [1] "1928-10-01" "1928-10-02" "1928-10-03" "1928-10-04" #or you can use this:  x<-as.Date(str1,format="%d%b%Y")  x [1] "1928-10-01" "1928-10-02" "1928-10-03" "1928-10-04" A.K. - Original M

Re: [R] Date formats

2012-06-19 Thread Rui Barradas
Hello, Try as.Date("01OCT1928", format="%d%b%Y") [1] "1928-10-01" Note that though probably not a problem to you, this is locale specific. In Portugal, the string corresponding to the same date would be "01OUT1928". The variable to set using Sys.setlocale() would be LC_TIME. For date forma

Re: [R] Date formats

2012-06-19 Thread Miguel Manese
Hi Walt, as.Date("01OCT1928", "%d%b%Y") works for me. See also ?strftime Regards, Jon On Tue, Jun 19, 2012 at 8:00 PM, Data Analytics Corp. wrote: > Hi, > > I imported an excel table (using read.csv) of Dow Jones monthly average > closings where the first variable is a date as a character str

Re: [R] Date formats

2012-06-19 Thread David Winsemius
On Jun 19, 2012, at 8:00 AM, Data Analytics Corp. wrote: Hi, I imported an excel table (using read.csv) of Dow Jones monthly average closings where the first variable is a date as a character string such as "01OCT1928". How do I convert this to a date variable so I can plot monthly aver

Re: [R] Date formats in as.Date

2009-09-24 Thread Gabor Grothendieck
Try this: > library(zoo) > as.yearmon("Sep-1981", "%b-%Y") [1] "Sep 1981" > as.Date(as.yearmon("Sep-1981", "%b-%Y")) [1] "1981-09-01" > as.Date(paste(1, "Sep-1981"), "%d %b-%Y") [1] "1981-09-01" On Thu, Sep 24, 2009 at 7:15 PM, Worik R wrote: > I have trouble with this: > > as.Date("Sep-1981"

Re: [R] Date formats in as.Date

2009-09-24 Thread Jim Porzak
Worik, You need a day! as in: as.Date("1-Sep-1981", format="%d-%b-%Y") ## first of the month HTH, Jim Porzak Ancestry.com San Francisco, CA www.linkedin.com/in/jimporzak use R! Group SF: www.meetup.com/R-Users/ On Thu, Sep 24, 2009 at 4:15 PM, Worik R wrote: > I have trouble with this: > >

Re: [R] Date formats

2007-12-30 Thread Mikkel Grum
, d, "1996-1-1") [[1]] [1] "1994-03-04" "1996-03-01" [[2]] [1] "1996-1-1" Any attempts to unlist, paste, etc. to remove the list structure converted/removed the Date class. Mikkel - Original Message From: Peter Dalgaard <[EMAIL PROTECTED]> To

Re: [R] Date formats

2007-12-30 Thread hadley wickham
On Dec 30, 2007 10:47 AM, Peter Dalgaard <[EMAIL PROTECTED]> wrote: > Gabor Grothendieck wrote: > > Read the warning in ?ifelse > Yep. > > And, yes, it is annoying that ifelse() strips attributes, including > class, but it is one of those things that have been in the S languages > "forever", and no

Re: [R] Date formats

2007-12-30 Thread Peter Dalgaard
Gabor Grothendieck wrote: > Read the warning in ?ifelse Yep. And, yes, it is annoying that ifelse() strips attributes, including class, but it is one of those things that have been in the S languages "forever", and nobody really wants to mess with. The fundamental issue is that you need the re

Re: [R] Date formats

2007-12-29 Thread Weiwei Shi
?ifelse will give you Warning The mode of the result may depend on the value of test, and the class attribute of the result is taken from test and may be inappropriate for the values selected from yes and no. i think it might answer your question, Weiwei On Dec 30, 2007 1:45 AM, Mikkel Grum <

Re: [R] Date formats

2007-12-29 Thread Gabor Grothendieck
Read the warning in ?ifelse On Dec 30, 2007 1:45 AM, Mikkel Grum <[EMAIL PROTECTED]> wrote: > Is the following expected behaviour for a date used in > an ifelse function? > > > date <- Sys.Date() > > date > [1] "2007-12-30" > > ifelse(TRUE, date-1, date) > [1] 13876 > > ifelse(FALSE, date-1, date)