[R] NA's in survey analysis

Donatas G. dgvirtual at akl.lt
Tue Dec 21 11:02:07 CET 2010


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
good code for a factor "NA" – it has to be the next number in the
factor list,so, might be different for each column in a data frame).
And besides, I have read somewhere in this list that IT IS THE WRONG

Is there the right way to do things that I want, and if not – what are
the possible workarounds, smarter than the ones I listed?

Donatas Glodenis

Donatas Glodenis

More information about the R-help mailing list