Message-Id: <3.0.3.32.19990625085650.0074b10c@pop.flash.net>
Date: Fri, 25 Jun 1999 08:56:50 -0500
To: "Z. Todd Taylor" <Todd.Taylor@pnl.gov>
From: John Thaden <jjthaden@flash.net>
Subject: Re: [R] coercing factors to matrix() --> num/char ? --
In-Reply-To: <199906231504.IAA11193@aggie.pnl.gov>
Peter Dalgaard:
>> Hm. I'm not sure there really is much logic in this... Factors are
>> sometimes character-like, sometimes integer-like.
Z. Todd Taylor:
>I'd be interested to hear a discussion of when they need to
>behave like integers.
Yesterday, using S+ 4.5 (Win), for instance:
#Exp is factor containing experiment numbers
>levels(mydata$Exp)
[1] "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12"
[14] "13" "14" "15" "16" "17" "18" "19"
>lm(y ~ x1 * x2, data=mydata, subset = Exp == 3 | Exp == 5,
+ weights = 5.5 - Exp)
Error in Ops.factor(5.5, Exp): "-" not meaningful for factors
Dumped
>lm(y ~ x1 * x2, data=mydata, subset = Exp == 3 | Exp == 5,
+ weights = 5.5 - as.integer(Exp) )
Error in lm.wfit(X, Y, weights, method): negative weights not allowed
Dumped
# . . . because as.integer(Exp) gives the codes as integers, not the
values, and
# the code for Exp 5 is 6.
> lm(y ~ x1 * x2, data=mydata, subset = Exp == 3 | Exp == 5,
+ weights = 5.5 - as.integer(as.character(Exp)))
Call:
lm(formula = y ~ x1 * x2, data = mydata,
#. . . Remainder of regression report truncated.
Z.T.T.:
>I can see the need to access the integers for
>"lower level" programming, for example, but when else?
ALL of my programming is "lower level"! ;-)
************************************************************
John J. Thaden, Ph.D., Instructor jjthaden@life.uams.edu
Department of Geriatrics (501) 257-5583
University of Arkansas for Medical Sciences FAX: (501) 257-4822
mail & ship to: J. L. McClellan V.A. Medical Center
Research-151 (Room GB103 or GC124)
4300 West 7th Street
Little Rock AR 72205 USA
***********************************************************
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._