[R] If-then with Dates in Date Ranges

jim holtman jholtman at gmail.com
Wed Sep 18 21:33:15 CEST 2013


You need to tell us what the objects are.  Are they vectors of some
type of data?  If so, what type, etc......

At least provide a subset of the data using 'dput' so we know what we
are looking at.

The 'if' statement will work fine is the objects are single valued;
you will need a different syntax if they are vectors of values and the
exact statement will depend on the data.

Please follow the posting guidelines.

Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Tue, Sep 17, 2013 at 1:52 PM, Zd Gibbs <zd.gibbs at yahoo.com> wrote:
> Hello everyone.
>
> I am very much a beginner with R and I am trying to turn the following if-then statement into R code. More detail. I want to create a new variable: "inperiod" that will be a numeric code. So if a specific event start date (StartDate) is greater or equal to a testing date (Beg1Date) AND the event end date (EndDate) is less than or equal to the testing date (Beg1Date), I want the inperiod code to be 1. I will do this for a range of dates so that the code can be anywhere from 1-25.
>
> If StartDate >= Beg1Date & EndDate <= Beg1Date inperiod = 1.
>
> Thanks for any help.
>
> Zeda
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list