a <-  c(1, 8, 9, 10, 8)
a[which(a==8)] <- NA

Nikhil

On Apr 6, 2010, at 7:31 AM, David Foreman wrote:

Dear All,

I seem entirely unable to solve what should be a very simple problem. I have imported a SPSS dataset into R using spss.get from Frank Harrell's Hmisc library. The variables are imported classed as 'labelled': missing values are coded as either the SPSS missing value code, 8 or 88. All are
imported correctly; 8 and 88 being identified as true numbers in the
'summary' command, which treats them (correctly) as numeric. For some
reason, is.na(x)<-c(8,88) doesn't seem to work. No error message is
returned, but the 8 and 88 are not set as NA. The example given in the help file does work, so is.na<- is functioning in my copy of R (2.10.1). I've tried working outside the dataframe, using unclass, as.numeric, and class<-
entirely without success.  The variable structure(exemplified by one
variable) is

Class 'labelled'  atomic [1:827] 2 2 2 2 2 2 8 NA 2 2 ...
..- attr(*, "label")= Named chr "In the last yr, you were unfairly treated
because of your sex"
 .. ..- attr(*, "names")= chr "c25a"

All suggestions are gratefully received!

Best wishes

David Foreman
Consultant and Visiting Professor in Child and Adolescent Psychiatry

        [[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.

Reply via email to