Skip to content
Prev 12015 / 398502 Next

changing values

Antonio Olinto wrote:

            
and 2 will be 1 and 3 and 4 will be 2, e.g.:
transformed in 1 1 1 1 2 1 2 2 ... ? (I have more than 200 lines in my
dataframe)
I don't know if it is the best way to do it, but it works:

x <- as.numeric(x)
x[x<=2] <- 1
x[x>2] <- 2
x <- as.factor(x)

Best regards,

Philippe Grosjean



...........]<(({?<...............<?}))><...............................
 ) ) ) ) )       __                      __
( ( ( ( (       |__)                    |  _
 ) ) ) ) )      |   hilippe             |__)rosjean
( ( ( ( (       Marine Biol. Lab., ULB, Belgium
 ) ) ) ) )                               __
( ( ( ( (       |\  /|                  |__)
 ) ) ) ) )      | \/ |ariculture &      |__)iostatistic
( ( ( ( (
 ) ) ) ) )      e-mail: phgrosje at ulb.ac.be
( ( ( ( (       SciViews project coordinator (http://www.sciviews.org)
 ) ) ) ) )
.......................................................................

-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20010628/12a718a7/attachment.html