Message-ID: <20090113115845.z9ylduyiaokk80gk@webmail.uni-bremen.de>
Date: 2009-01-13T10:58:45Z
From: Patrick Hausmann
Subject: NA-values and logical operation
Dear list,
as a result of a logical operation I want to assign
a new variable to a DF with NA-values.
z <- data.frame( x = c(5,6,5,NA,7,5,4,NA),
y = c(1,2,2,2,2,2,2,2) )
p <- (z$x <= 5) & (z$y == 1)
p
z[p, "p1"] <-5
z
# ok, this works fine
z <- z[,-3]
p <- (z$x <= 5) & (z$y == 2)
p
z[p, "p2"] <-5
z
# this failed... - how can I assign the value '5' to the new
# var "p2"
Thanks for any help!!
Patrick