Say I have a dataframe with df$Cat, df$IsYellow. Both columns can either be "Yes" or "No"
How do I generate the 2x2 table and also have Cat and IsYellow printed on the table so that I know which side of the table belongs to Cat and which side belongs to IsYellow?
df <- data.frame(Cat=sample(c('Yes', 'No'), size=10, replace=TRUE),
IsYellow=sample(c('Yes', 'No'), size=10, replace=TRUE))
table(df)
## IsYellow
## Cat No Yes
## No 3 1
## Yes 2 4
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.