Re: [R] Converting Excel Date format into R-Date formats

2017-02-12 Thread Jim Lemon
Hi Jeff, Most likely the "Event Date" field is a factor. Try this: df$Event.Date <- as.Date(as.character(df$Event.Date), "%d-%b-%y") Also beware of Excel's habit of silently converting mixed date formats (i.e. dd/mm/ and mm/dd/) to one or the other format. The only way I know to prevent

[R] Converting Excel Date format into R-Date formats

2017-02-12 Thread Jeff Reichman
R-Help Group What is the proper way to convert excel date formats to R-Date format. Event ID Event Date Event Type 250013 1-Jan-09 NSAG Attack 250015 1-Jan-09 NSAG Attack 250016 1-Jan-09 NSAG Attack Obviously this is wrong df$Event.Date <- as.Date(df$Event.Da

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
="%d%b%Y")  x [1] "1928-10-01" "1928-10-02" "1928-10-03" "1928-10-04" A.K. ----- Original Message - From: Data Analytics Corp. To: r-help@r-project.org Cc: Sent: Tuesday, June 19, 2012 8:00 AM Subject: [R] Date formats Hi, I imported a

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

[R] Date formats

2012-06-19 Thread Data Analytics Corp.
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 average closings against date using ggplot2? Thanks, Walt _

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: > >

[R] Date formats in as.Date

2009-09-24 Thread Worik R
I have trouble with this: as.Date("Sep-1981", format="%b-%Y") Returns "NA" >From documentation for strftime '%b' Abbreviated month name in the current locale. (Also matches full name on input.) '%Y' Year with century. What am I doing wrong? cheers Worik [[alternative H

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)

[R] Date formats

2007-12-29 Thread Mikkel Grum
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) [1] 13877 > ifelse(TRUE, as.character(date-1), date) [1] "2007-12-29" > if (TRUE) {date} [1] "2007-12-30" It