----- Original Message -----
Sent: Thursday, July 26, 2001 5:44
PM
Subject: RE: [S]
Try
all$group <- ifelse(as.numeric(as.character(all$kod)) < 1404, "D", "ND")
If it's a
factor that has levels "10", "2", "7" then coercing it to numeric simply makes
it 1, 2, 3, because that's how factors are coded. You need to convert to
character first then convert those characters into
numbers.
Nick Ellis
CSIRO Marine Research mailto:Nick.Ellis@marine.csiro.au
PO
Box 120
ph +61 (07) 3826
7260
Cleveland QLD 4163 fax +61 (07)
3826 7222
Australia
http://www.marine.csiro.au
Dear S-Plus Users,
Hi! I am trying to use the "ifelse" command to create a
new variable "group". However I received an error message below. It seemed
that the variable kod is read as "factors". So I've change the "data
type" for kod from "factors" to "double" using the window menu. But the
kod value change to new numbers altogether. Can any one advised me to solve
this problem.
all$group <- ifelse(all$kod < 1404,
"D", "ND")
Error in Ops.factor(all$kod, 1404):
"<" not meaningful for factors
Thanks
Abd. Rahman Kassim