[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-help
Subject:    Re: [R] NA's in survey analysis
From:       "Donatas G." <dgvirtual () akl ! lt>
Date:       2010-12-21 12:19:46
Message-ID: AANLkTi=sNhOD9J+ErRL1StwnVQDOxLoz71Prg8VX8sOg () mail ! gmail ! com
[Download RAW message or body]

2010/12/21 Petr PIKAL <petr.pikal@precheza.cz>:
> Hi
>
> r-help-bounces@r-project.org napsal dne 21.12.2010 11:02:07:
>
>> Hello,
>>
>> I am trying to analyze sociological survey data using R. It is often
>> important in survey to calculate both the actual factor sums and
>> percentages (easily done with describe() ), but also the numbers and
>> total percentage of NA's. Often it is important to present NA's in
>> graphs besides the factors.
>>
>> Is there any easy way to make R treat NA's as if those were factors
>> besides other factors?
>>
>> Now, describe(data$a) gives me percentages only for the factors. So I
>> have to redo percentages manually.
>>
>> barplot() also ignores NA's. So, to include NA's into barplot I need
>> to do a table more or less manually.
>>
>> The other way to do it is to convert NA's into factors (doable,
>> although, unlike in SPSS, I cannot make an assumption that 99 is a
>
> not necessary to code missing values, you can set NA as one level.
>
> x<-factor(sample(c(1:3, NA),20,replace=T), exclude=NULL)
> x
>  [1] 1    1    3    3    3    2    3    <NA> 3    1    2    <NA> 3    <NA>
> 2
> [16] 2    3    1    <NA> 3
> Levels: 1 2 3 <NA>
>> y<-rnorm(20)
> boxplot(split(y,x))
>
> Besides you could find it from factor help page as I did.
>
> Regards
> Petr

Thank you Petr, this info (re exclude=NULL) might have saved me tons
of time last week :)

I still have not found an equivalent parameter in describe(), but
anyway, I have been helped a lot!

-- 
Donatas Glodenis

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic