mr_count | R Documentation |
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.
mr_count(x, na.rm = TRUE) mr_drop(x, levels,...) ms_drop(x, levels) mr_na(x, na=TRUE) ms_na(x)
x |
|
na.rm |
Remove |
levels |
character vector of levels to remove |
na |
Value ( |
... |
not used |
An integer vector for mr_count
, an object of class mr
, or ms
for the other two functions
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.