Re: [R] error in IF condition with factor evaluation

2012-11-23 Thread PIKAL Petr
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Rui Barradas > Sent: Friday, November 23, 2012 2:37 PM > To: edoardo baldoni > Cc: R-help@r-project.org > Subject: Re: [R] error in IF condition w

Re: [R] error in IF condition with factor evaluation

2012-11-23 Thread Rui Barradas
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

Re: [R] error in IF condition with factor evaluation

2012-11-23 Thread Eik Vettorazzi
Hi Edoardo, there is a difference between comparisons and assignments, both semantically as well as in R syntax: "==" vs "=" or "<-", latter being more obvious an assignment. This is the source of your error. But to change the labels of a factor object, it is easier to do sth like at<-factor(1:5,l

[R] error in IF condition with factor evaluation

2012-11-23 Thread edoardo baldoni
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 P