mr_count {rimu} | R Documentation |
Utility functions for multiple-response objects
Description
These perform diverse useful tasks. mr_count
counts the number of levels present for each individual. mr_na
sets NA
values to something else, ms_na
sets them to 0 (ie, not present),
mr_drop
and ms_drop
drop some levels from the object.
Usage
mr_count(x, na.rm = TRUE)
mr_drop(x, levels,...)
ms_drop(x, levels)
mr_na(x, na=TRUE)
ms_na(x)
Arguments
x |
|
na.rm |
Remove |
levels |
character vector of levels to remove |
na |
Value ( |
... |
not used |
Value
An integer vector for mr_count
, an object of class mr
, or ms
for the other two functions
Examples
data(usethnicity)
race<-as.mr(strsplit(as.character(usethnicity$Q5),""))
mtable(race)
race<-mr_drop(race,c(" ","F","G","H"))
mtable(race)
## to keep just specified levels use [
mtable(race[,c("A","D")])
## How many do people identify with
table(mr_count(race))
data(nzbirds)
seenbirds<-as.mr(nzbirds>0)
countbirds<-mr_count(seenbirds)
## How many types of birds were seen
table(countbirds)
data(ethnicity)
ethnicity
mr_na(ethnicity, FALSE)
[Package rimu version 0.6 Index]