![](/img/trans.png)
[英]How do I get the column names for ALL the nth CONSECUTIVE occurrence of a value in a data table row using R
[英]R table() function; how do I get column names included?
假設我有一個帶有 df$Cat、df$IsYellow 的數據框。 兩列都可以是“是”或“否”
如何生成 2x2 表並在表上打印 Cat 和 IsYellow,以便我知道表的哪一側屬於 Cat,哪一側屬於 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.