Re: [R] if negative value, make zero

2010-05-28 Thread Joshua Wiley
Hi, It did not return the results you wanted because you tried to feed the entire data frame to ifelse(). Does something like this do what you want? apply(tempr, 2, function(x) {ifelse(x < 0, 0, x)}) Josh On Fri, May 28, 2010 at 8:37 AM, wrote: > I have a data frame with both positive and n

Re: [R] if negative value, make zero

2010-05-28 Thread Peter Langfelder
temp2 = tempr temp2[temp2<0] = 0 HTH On Fri, May 28, 2010 at 8:37 AM, wrote: > I have a data frame with both positive and negative values, and I want to > make all the negative values equal zero, so i can eventually take an > average. > I've tried > temp2 <- ifelse(tempr<0, 0, tempr) > but it