Does the following do what you want?
> f <- factor(c("A","B","C"))
> f
[1] A B C
Levels: A B C
> levels(f) <- c("A","B","B")
> f
[1] A B B
Levels: A B
Andy
-----Original Message-----
From: Gerald.Jean@spgdag.ca [mailto:Gerald.Jean@spgdag.ca]
Sent: Monday, November 25, 2002 10:04 AM
To: s-news@wubios.wustl.edu
Subject: [S] Creating and merging factor levels
Hello S-users,
when creating factors is it possible to merge levels of a character
variable as the factor is created? In other words can the following be
done in one operation.
ttt <- factor(ttt.char, levels = c("N", "O", "S")
ttt <- merge.levels(ttt, k = list(" Non" = "N",
" Oui" = c("O", "S")))
Thanks,
Gérald Jean
Analyste-conseil (statistiques), Actuariat
télephone : (418) 835-4900 poste (7639)
télecopieur : (418) 835-6657
courrier électronique: gerald.jean@spgdag.ca
"In God we trust all others must bring data" W. Edwards Deming
--------------------------------------------------------------------
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
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may
be confidential, proprietary copyrighted and/or legally privileged, and 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 immediately return this by e-mail and then delete it.
==============================================================================
|