Replaced stars with NA has no effect when data is read from a function in R -


i have data frame missing values denoted star sign "*".

i have replaced them > mydata[mydata == "*"] <- na when use str(mydata) shows missing values still "*". like

'data.frame':   117 obs. of  8 variables:  $ price: factor w/ 82 levels "*","1000","1020",..: 36 37 39 39 35 34 32 29 27 26 ... 

as if have not applied > mydata[mydata == "*"] <- na

it's not mydata equal "*" rather mydata$price

try 1 of these , first of coerce numeric vector , in process generate warning values being set na can ignored, since wanted in first place:

 mydata$price  <- as.numeric(as.character( mydata$price))   mydata$price[ mydata$price == "*" ] <- na   is.na(my mydata$price) <-  mydata$price == "*" 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -