On Jan 2, 2012, at 10:42 AM, David Winsemius wrote:


On Jan 2, 2012, at 4:11 AM, Richard Kolodziej wrote:

Hello,

I'm using SPSS at work but really would like to switch to R. Right now I'm trying to learn R in reproducing calculations I did with SPSS but am stuck with something that is quite simple and comprehensible in SPSS- Syntax:

IF (variable1.fac = 0 AND variable2.num = 0) variable3=1.
IF (variable1.fac = 0 AND variable2.num >= 1) variable3=2.
IF (variable1.fac = 1 AND variable2.num = 0) variable3=3.
IF (variable1.fac = 1 AND variable2.num >= 1) variable3=4.


https://stat.ethz.ch/pipermail/r-help/2008-November/178808.html looked
promising but didn't do what I had intended

(I think the results of interaction( variable1.fac = 0 , variable2.num = 0) should have dome very nicely, but if you wanted them a naked numbers then this would have also givne satisfaction:

var3 <- as.numeric( interaction( variable1.fac = 0 , variable2.num = 0) )

Well that should be filed under embarrassing contributions. Try instead:

var3 <- as.numeric( interaction( variable1.fac == 1 , variable2.num >= 1) )


--
David



David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@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.

Reply via email to