Both vector query's can select the values from the data.frame as written,
however in the first form assigning a value to said selected numbers fails.
 Can you explain the reason this fails?

dat <- data.frame(index = 1:10, Value = c(1:4, NA, 6, NA, 8:10))

dat$Value[dat$Value == "NA"] <- 1 #Why does this  fails to work,
dat$Value[dat$Value %in% NA] <- 1 #While this does work?


#Particularly when str() results in an equivalent class
dat <- data.frame(index = 1:10, Value = c(1:4, NA, 6, NA, 8:10))
str(dat$Value[dat$Value %in% NA])
str(dat$Value[dat$Value == "NA"])

Thanks
Pat


-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to