Something like:
> dat <- data.frame(FACTOR=c("A", "B", "C"), x=1:3, y=4:6)
> summary(dat)
FACTOR x y
A:1 Min. :1.0 Min. :4.0
B:1 1st Qu.:1.5 1st Qu.:4.5
C:1 Median :2.0 Median :5.0
Mean :2.0 Mean :5.0
3rd Qu.:2.5 3rd Qu.:5.5
Max. :3.0 Max. :6.0
> levels(dat$FACTOR) <- c("XXX", "XXX", "C")
> summary(dat)
FACTOR x y
XXX:2 Min. :1.0 Min. :4.0
C :1 1st Qu.:1.5 1st Qu.:4.5
Median :2.0 Median :5.0
Mean :2.0 Mean :5.0
3rd Qu.:2.5 3rd Qu.:5.5
Max. :3.0 Max. :6.0
??
HTH,
Andy
-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Smeets, S
(Sjoerd)
Sent: Wednesday, September 29, 2004 10:47 AM
To: s-news@lists.biostat.wustl.edu
Subject: [S] Recode factor variabels
Hi,
I have a dataframe TEST with 3 columns. The column FACTOR consists of factor
variabels. I want to recode the values A and B into XXX. Can this be done
using a script? And how can this be done?
Thanks in advance,
Sjoerd Smeets
================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht
onterecht ontvangt, wordt u verzocht de inhoud niet te gebruiken en
de afzender direct te informeren door het bericht te retourneren.
================================================
The information contained in this message may be confidential
and is intended to be exclusively for the addressee. Should you
receive this message unintentionally, please do not use the contents
herein and notify the sender immediately by return e-mail.
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New
Jersey, USA 08889), and/or its affiliates (which may be known outside the
United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as
Banyu) that may be confidential, proprietary copyrighted and/or legally
privileged. It is intended solely for the use of the individual or entity named
on this message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and then delete
it from your system.
------------------------------------------------------------------------------
|