Hello,
Try
if (!is.na(x[i]) && x[i] == "DISCONECTED")
Hope this helps,
Rui Barradas
Em 23-11-2012 09:42, edoardo baldoni escreveu:
Cam anyone tell me why the condition x[i] == "DISCONECTED" looks like
producing an NA instead of TRUE/FALSE
I would like to rename "DISCONNECTED" those factors inside the variable
"dataset$STATUS.x" that are named "DISCONECTED"
thank you
summary(dataset$STATUS.x)
ACTIVE DISCONECTED PENDING SUSPENDED TERMINATED
158869 169181 3028 8565 47233
NA's
6
class(dataset$STATUS.x)
[1] "factor"
fff = function(x) {
+ for (i in 1:length(x)){
+ if (x[i] == "DISCONECTED") {
+ x[i] == "DISCONNECTED"
+ } else x[i] == x[i]
+ }
+ return(x)
+ }
r = fff(dataset$STATUS.x)
Error in if (x[i] == "DISCONECTED") { :
missing value where TRUE/FALSE needed
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org 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.
______________________________________________
R-help@r-project.org 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.