Re: [R] problem with if else statement

2010-06-08 Thread Petr PIKAL
> To: r-help@r-project.org > Subject: [R] problem with if else statement > > Dear colleagues, > > What did I not understand ? > > ->my intention > I want to create a new variable: > In plain language: > If someone is taking anithypertensive treatment (med.hy

Re: [R] problem with if else statement

2010-06-08 Thread Martyn Byng
lf Of Peter Lercher Sent: 08 June 2010 10:18 To: r-help@r-project.org Subject: [R] problem with if else statement Dear colleagues, What did I not understand ? ->my intention I want to create a new variable: In plain language: If someone is taking anithypertensive treatment (med.hyper==1) table(m

Re: [R] problem with if else statement

2010-06-08 Thread Rafael Björk
Hi Peter! The 'if' function operate on a single logical expression, while you provided a vector. What your code does at present is subtract 5 from all values in rr.dia.2m if the first value in med.hyper is 1 and otherwise simply returns all values as is. Since you have no reproducible data, it's h

[R] problem with if else statement

2010-06-08 Thread Peter Lercher
Dear colleagues, What did I not understand ? ->my intention I want to create a new variable: In plain language: If someone is taking anithypertensive treatment (med.hyper==1) table(med.hyper) med.hyper 0 1 472 97 I want to subtract 5 mmHg (rr.dia.2m-5) from the measured diastolic blood pres