Re: [R] Studdy Missing Data, differentiate between a percent with in the valid answers and with in the different missing answers

From: James Reilly <reilly_at_stat.auckland.ac.nz>
Date: Mon, 03 Mar 2008 22:02:17 +1300

On 3/3/08 8:21 PM, Ericka Lundström wrote:
> I'm trying to emigrate from SPSS to R, thou I have some problems whit
> getting R to distinguish between the different kind of missing.
...
> Is there a smart way in R to differentiate between missing and valid
> and at the same time treat both the categories within missing and
> valid as answers (like SPSS did above)

The Hmisc package has some support for special missing values, for instance when reading in SAS datasets using sas.get. I don't believe spss.get offers the same facility, though.

You can define special missing values for a variable manually, which might seem a bit involved, but this could easily be automated. For your example, try:

special <- dataFrame$TWO %in% c("?","X") attr(dataFrame$TWO, "special.miss") <-

     list(codes=as.character(dataFrame$TWO[special]),
     obs=(1:length(dataFrame$TWO))[special])
class(dataFrame$TWO) <- c("factor", "special.miss") is.na(dataFrame$TWO) <- special

# Then describe gives new percentages

describe(dataFrame$TWO)
dataFrame$TWO

       n missing       ?       X  unique
       3       4       2       2       2

No (2, 67%), yes (1, 33%)

HTH,
James

-- 
James Reilly
Department of Statistics, University of Auckland
Private Bag 92019, Auckland, New Zealand

______________________________________________
R-help_at_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.
Received on Mon 03 Mar 2008 - 09:06:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 03 Mar 2008 - 15:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive