[R] Using dates in R

Brian Hamel bh1605a at student.american.edu
Wed Mar 4 15:54:52 CET 2015


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 column, and a
"1" otherwise. Note that my dataset includes dates from 1979-2012, so it is
not one-year (this means I can't easily create a new variable 1-365).

How does R handle dates? My hunch is "not well," but perhaps there is a
package that can help me with this. Let me know if you have any
recommendations as to how this can be done relatively easily.

Thanks! Appreciate it.

Best,
Brian

	[[alternative HTML version deleted]]



More information about the R-help mailing list