[19028] in s-news-athena
[S] Adding a level to a factor.
daemon@ATHENA.MIT.EDU (=?iso-8859-1?Q?"G=E9rald_Jean"?=)
Tue Aug 24 12:52:42 1999
From: =?iso-8859-1?Q?"G=E9rald_Jean"?= <Gerald.Jean@spgdag.ca>
To: s-news@wubios.wustl.edu
Message-Id: <852567D7.005B218F.00@mail.spgdag.com>
Date: Tue, 24 Aug 1999 12:48:28 -0400
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
Hi there,
Suppose I have a factor variable with 2 levels.
> levels(ttt.dcontra)
[1] "N" "O"
But in fact there is a whole lot of missing values in that variable.
> summary(ttt.dcontra)
N O NA's
5639 7468 4593
The missing values mean something to me and I'd like to assign them some
factor level,
"Missing" say, that S+ will treat as a valid level in further analysis, in
regression
for exemple. How do I do that?
If I try to assign a value to the "NA's", S+ complains.
> ttt.dcontra[which.na(ttt.dcontra)] _ 'Missing'
Warning messages:
replacement values not all in levels(x): NA's generated in:
"[<-.factor"(ttt.d
contra, which.na(ttt.dcontra), value = "Missing")
If I try to assign a new level to the variable, S+ complains again.
> levels(ttt.dcontra) _ edit(levels(ttt.dcontra))
Error in "levels<-.factor"(ttt.dcontra, edit(level..: number of levels
differs:
2 old, 4
I don't have anymore ideas, any help would be appreciated, I'll summarize
to the list.
Gérald Jean
Analyste-conseil (statistiques), Actuariat
télephone : (418) 835-8839
télecopieur : (418) 835-5865
courrier électronique: gerald.jean@spgdag.ca
"In God we trust all others must bring data"
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news