Hello again.
I don't understand what didn't work.
First, it seems better to use 'nrow', the result is the same
stopifnot(length(x[,1]) == nrow(x))
Then your multiple OR condition.
#if((x[i,1] || x[i,2] || x[i,3] || x[i,4]) < 5)
x <- matrix(1:24, ncol=4)
for(i in 1:nrow(x))
if(any(x
On 24.12.2011 12:03, reena wrote:
It didn't work. :(
What did not work???
Please do not misuse the R-help mailing list! Its posting guide clearly
asks you to cite the thread and specify reproducible examples that make
other able to help.
Best,
Uwe Ligges
--
View this message in cont
It didn't work. :(
--
View this message in context:
http://r.789695.n4.nabble.com/if-statement-problem-tp4230026p4230933.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/lis
This is almost Circle 8.1.7 of
'The R Inferno':
http://www.burns-stat.com/pages/Tutor/R_inferno.pdf
but is making the mistake in the
other direction.
On 23/12/2011 22:40, reena wrote:
Hello,
I want to do fisher test for the rows in data file which has value less than
5 otherwise chi square te
reena wrote
>
> Hello,
>
> I want to do fisher test for the rows in data file which has value less
> than 5 otherwise chi square test .The p values from both test should be
> stored in one resulted file. but there is some problem with bold if
> statement. I don't know how
> implement this line
Hello,
I want to do fisher test for the rows in data file which has value less than
5 otherwise chi square test .The p values from both test should be stored in
one resulted file. but there is some problem with bold if statement. I don't
know how
implement this line properly.
x = cbind(obs1,obs
Try:
das$danger <- with(das, (age > 65) * (bmi > 30))
On Jan 1, 2008 5:03 PM, Gerard Smits <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have a small dataset named das (43 cases) in which I am trying to
> create a binary outcome (1/0) based on the following code:
>
> if (das$age>65 && das$bmi>30) {
Hi Domenico,
I was incorrectly assuming it would use a vector of equal length to
my data. frame. Thanks for the clarification.
Also, thanks for the many alternate programming approaches provided by others.
Gerard
At 02:25 PM 1/1/2008, Domenico Vistocco wrote:
>You should look for your answer
08, Christos Hatzis wrote:
> >You need to use '&' instead of '&&':
> >
> >A shorter version of your code using ifelse:
> >
> >das$danger <- with(das, ifelse(age>65 & bmi>30, 1, 0))
> >
> >HTH
> >
> >-Chr
You should look for your answer using the help for the if statement (?"if").
The cond argument should be a scalar (otherwise only the first element
is used).
?"if"
.
cond: A length-one logical vector that is not 'NA'. Conditions of
length greater than one are accepted with a warnin
mp; bmi>30, 1, 0))
>
>HTH
>
>-Christos
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Gerard Smits
> > Sent: Tuesday, January 01, 2008 5:04 PM
> > To: r-help@r-project.org
> > Subject: [R] i
On Behalf Of Gerard Smits
> Sent: Tuesday, January 01, 2008 5:04 PM
> To: r-help@r-project.org
> Subject: [R] if statement problem
>
> Hi All,
>
> I have a small dataset named das (43 cases) in which I am
> trying to create a binary outcome (1/0) based on the following code
Hi All,
I have a small dataset named das (43 cases) in which I am trying to
create a binary outcome (1/0) based on the following code:
if (das$age>65 && das$bmi>30) {das$danger<-1} else das$danger<-0
I am setting a flag called 'danger' to 1 of the subject is over 65
and has a BMI > 30.
I fin
13 matches
Mail list logo