Re: [R] Help with if statements

2009-06-09 Thread Carl Witthoft
> Error in if (ALLRESULTS[i, 16] <= 0.05) significance_count = significance_count + : > missing value where TRUE/FALSE needed > > The script is included below > > it works if i convert the NA values to zero but this is not appropriate as it includes the zero as significant. > > ANY SUGGESTION

Re: [R] Help with if statements

2009-06-09 Thread Chuck Cleland
On 6/9/2009 12:17 PM, Amit Patel wrote: > Hi > I am trying to create a column in a data frame which gives a sigificane score > from 0-7. It should read values from 7 different colums and add 1 to the > counter if the value is <=0.05. I get an error message saying > > Error in if (ALLRESULTS[i,

Re: [R] Help with if statements

2009-06-09 Thread Jorge Ivan Velez
Dear Amit, Try this: significance_count <- apply( ALLRESULTS[,16:22], 1, function(x) sum( x <= 0.05 ) ) ) HTH, Jorge On Tue, Jun 9, 2009 at 12:17 PM, Amit Patel wrote: > > Hi > I am trying to create a column in a data frame which gives a sigificane > score from 0-7. It should read values fro

Re: [R] Help with if statements

2009-06-09 Thread Linlin Yan
Try this: for (i in 1:dim(ALLRESULTS)[1]) { ALLRESULTS[i,23] <- length(ALLRESULTS[i,][ALLRESULTS[i,16:22] <= 0.05]) } On Wed, Jun 10, 2009 at 12:17 AM, Amit Patel wrote: > > Hi > I am trying to create a column in a data frame which gives a sigificane score > from 0-7. It should read values from

[R] Help with if statements

2009-06-09 Thread Amit Patel
Hi I am trying to create a column in a data frame which gives a sigificane score from 0-7. It should read values from 7 different colums and add 1 to the counter if the value is <=0.05. I get an error message saying Error in if (ALLRESULTS[i, 16] <= 0.05) significance_count = significance_cou