How about the following:
tst.data <- data.frame(a=seq(0, 2, length=9), b=seq(0, 2, length=9))
round(tst.data)
Alternatively:
(tst.data>=.5)+(tst.data>1.5)
Do these do work for you?
Best Wishes,
Spencer Graves
Frank Lawrence wrote:
I would like to know how to quickly recode multiple variables. In one
problem I have, I need to recode the data in a 600 x 200 data frame so that
values less than 0.5 are scored 0, those equal to or greater than 1.5 are
scored 2, and those in between are scored 1. Using loops seems to take a
very long time. Is there a more efficient way to accomplish the recode?
WIN 2k, Splus 6.1
Respectfully,
Frank R. Lawrence
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|