Hello,
thanks for the quick answers! Some answers were more useful to me than
others but I really appreciate everybodys effort, reading and
answering my question.
I will try Dons approach because as he said, it looks quite readable.
I'll need to take a closer look on the nested ifelse statements
On Jan 2, 2012, at 4:22 PM, David Stevens wrote:
Could it be
NO. You are not reading the documentation for "if" carefully enough,
despite several efforts to point you in the right direction. You
cannot make literal transliterations of SPSS syntax work in the manner
you imagine.
--
Dav
Could it be
if(variable1.fac == 0 & variable2.num == 0) {variable3 = 1} #
brackets {} aren't strictly required for a one liner.
if(variable1.fac == 0 & variable2.num >= 0) {variable3 = 2} #
brackets {} aren't strictly required for a one liner.
if(variable1.fac == 1 & variable2.nu
I usually do this kind of thing like this:
variable3 <- rep(1,length(variable1.fac))
variable3[ variable1.fac == 0 & variable2.num >= 1 ] <- 2
variable3[ variable1.fac == 1 & variable2.num == 0 ] <- 3
variable3[ variable1.fac == 1 & variable2.num >= 1 ] <- 4
This approach is easy to read and unde
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 qu
Dear Richard,
You can do this with some nested ifelse statements.
Assuming variable2.num has only positive integers and variable1.fac is only 0
or 1
Variable3 <- ifelse(variable1.fac == 0, ifelse(variable2.num == 0, 1, 2),
ifelse(variable2.num == 0; 3; 4))
A more fancy solution
as.numeric(fac
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 (var
7 matches
Mail list logo