[R] if and

Val valkremk at gmail.com
Tue Feb 28 02:47:58 CET 2017


Currently I have  about  six or more  scripts that do the same job.  I
thought it might be possible and more efficient to use one script by using
IF ELSE statements. Here is an example but this will be expandable for
several countries ans year-months


Year-month = FEB2015, FEB2012,  Feb2010
 country  = USA, CAN.MEX
First I want to do if country = USA and year-month = FEB2015, FEB2012 do
the statements
second if country = CAN and year-month =Feb2010 do  the statements


if(country="USA" & year-month = "FEB2015" | "FEB2012" ){
statemnt1
.
statemnt10

} else if (country="USA" & year-month ="FEB2015") {
statemnt1
.
statemnt10
}

else
{
statemnt1
.
statemnt10
}

The above script did not work. is there a different ways of doing it?

Thank you in advance
.

	[[alternative HTML version deleted]]



More information about the R-help mailing list