Re: [R] Using dates in R

2015-03-04 Thread Steve Taylor
> today <- as.Date("2015-03-04") # default format Better is: today <- Sys.Date() S -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap Sent: Thursday, 5 March 2015 7:47a To: Brian Hamel Cc: r-help@r-project.org Subject:

Re: [R] Using dates in R

2015-03-04 Thread Myfanwy Johnston
Our R-user's group (UC Davis) has a good post on working with dates/times in R: http://www.noamross.net/blog/2014/2/10/using-times-and-dates-in-r---presentation-code.html On Wed, Mar 4, 2015 at 11:08 AM, David L Carlson wrote: > Wow! A bold prediction from someone who has done exactly zero > i

Re: [R] Using dates in R

2015-03-04 Thread David L Carlson
Wow! A bold prediction from someone who has done exactly zero investigation of the basic, built-in date/time features in R. Since your example did not include the first two digits of the year, I've used %y instead of %Y. That will assume "19" precedes values from 69-99 and "20" precedes values f

Re: [R] Using dates in R

2015-03-04 Thread Peter Alspach
Tena koe Brian See ?as.Date and ?strptime (and, maybe, ?locales). For example: as.Date('2/15/15', '%m/%d/%y') [1] "2015-02-15" as.Date('12/15/14', '%m/%d/%y') < as.Date('2/15/15', '%m/%d/%y') [1] TRUE > as.Date('12/15/16', '%m/%d/%y') < as.Date('2/15/15', '%m/%d/%y') [1] FALSE You might have p

Re: [R] Using dates in R

2015-03-04 Thread William Dunlap
You will need to convert strings like "2/15/15" into one of the time/date classes available in R and then it is easy to do comparisons. E.g., if you have no interest in the time of day you can use the Date class: > d <- as.Date(c("12/2/79", "4/15/15"), format="%m/%d/%y") > today <- as.Date("2015-

Re: [R] Using dates in R

2015-03-04 Thread MacQueen, Don
Your hunch is wrong. Start by typing ?Date at the R prompt. Continue with ?as.Date Then to find out if the date is earlier than today delta <- thedate - Sys.Date() (of course, that will change if you use it tomorrow) Getting your indicator variable can be done very easily with base R; no