Learn R Programming

rimu (version 0.6)

mr_union: Set operations on multiple-response objects

Description

These functions take union, intersection, and difference of two multiple-response objects. An observation has a level in the union if it has that level in either input. It has the level in the intersection if it has the level in both inputs. It has the level in the difference if it has the level in x and not in y

Usage

mr_union(x, y,...)
mr_intersect(x, y,...)
mr_diff(x, y,...)

Value

Object of class mr

Arguments

x,y

Objects of class mr

...

not used

Examples

Run this code

data(usethnicity)
race<-as.mr(usethnicity$Q5,"")
race<-mr_drop(race,c(" ","F","G","H"))
race <- mr_recode(race, AmIndian="A",Asian="B", Black="C", Pacific="D", White="E")
mtable(race)

hispanic<-as.mr(usethnicity$Q4==1, "Hispanic")
ethnicity<-mr_union(race, hispanic)
mtable(ethnicity)
ethnicity[101:120]


Run the code above in your browser using DataLab