Monday, April 8, 2013

RG#41: Mosaic plot: visualization of categorical data

# data 
set.seed (1234)
myd <- data.frame (fact1 = sample (c("A", "B", "C", "D"), 200, replace = TRUE), 
fact2 = sample (c("HL", "PS",  "DS"), 200, replace = TRUE), 
fact3 = sample (c("Male", "Female"), 200, replace = TRUE))


#plot 
# vcd package is for visualization of categorical data 
require(vcd)
mytable <- table (myd)
mosaic(mytable, shade=TRUE, legend=TRUE)



No comments:

Post a Comment

Note: Only a member of this blog may post a comment.