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
Department of Anthropology > Texas A&M University > College Station, TX 77840-4352 > > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Brian > Hamel > Sent: Wednesday, March 4, 2015 8:55 AM > To: r-help@r-project.org > Sub

Re: [R] Using dates in R

2015-03-04 Thread David L Carlson
University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Brian Hamel Sent: Wednesday, March 4, 2015 8:55 AM To: r-help@r-project.org Subject: [R] Using dates in R Hi all, I have a dataset that includes a "date"

Re: [R] Using dates in R

2015-03-04 Thread Peter Alspach
;%m/%d/%y') [1] TRUE HTH ... P -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Brian Hamel Sent: Thursday, 5 March 2015 3:55 a.m. To: r-help@r-project.org Subject: [R] Using dates in R Hi all, I have a dataset that includes a "date" varia

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

[R] Using dates in R

2015-03-04 Thread Brian Hamel
Hi all, I have a dataset that includes a "date" variable. Each observation includes a date in the form of 2/15/15, for example. I'm looking to create a new indicator variable that is based on the date variable. So, for example, if the date is earlier than today, I would need a "0" in the new colum