-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
Of Virgile Capo-Chichi
Sent: Tuesday, November 20, 2012 11:09 AM
To: r-help at r-project.org
Subject: [R] Using if
Dear R users,
As a new comer to R, I would like to create a new variable using if
statements but don't know how to do it. Basically, I have two variables
(EvHint and MinTex). I want to create a third variable called RiskTest.
In SPSS, my syntax would look like
Compute RiskTest=0.
if (EvHint=1 & MinTex=1) RiskTest=1.
Question: How do I do this with R?
My Data
EvHint<-c(0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0)
MinTex<-c(0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0)
Thanks, V
[[alternative HTML version deleted]]