[R] Seeing negative numbers to zero
dbuehler2001 at yahoo.com
Fri Aug 7 22:29:16 CEST 2009
I am also new to R and I have a related question. I am trying to set
negative values in a single column of a dataframe to zero and I can't seem
to do it.
I have tried:
# Here I am selecting the column of the dataframe KN1 and assigning it the
name KN2 - this step works
# Here I am trying to set negative numbers to zero and leave all other
numbers the same - this doesn't work
Any help would be appreciated.
> see ?ifelse
> you didn't specify what happens if a value is exactly zero in the dataset
> and so i've just bundled it in with the negative case:
> x <- rnorm(20, 0, 1)
> y<-ifelse(x<=0, 10, 5)
> Tony Breyal
> cmga20 wrote:
>> Hi i am very new to R and I have been trying to change each individual
>> piece of data in a data set to 10 if it is below 0 and 5 if it is above
>> 0. I know this sounds very easy but i am struggling!!
View this message in context: http://www.nabble.com/For-loop-for-distinguishing-negative-numbers-tp24499872p24870518.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help