R原因列联表table()函数

    xiaoxiao2021-12-14  16

    一、table 函数对应的就是统计学中的列联表,是一种记录频数的方法,对于统计来说有非常重要的应用,下面的例子都是针对维数为2的情况举例,多维的情况是类似的

    ct <- data.frame(Vote.for.X = factor(c("Yes", "Yes", "No", "Not Sure", "No"), levels = c("Yes", "No", "Not Sure")),ote.for.X.Last.Time = factor(c("Yes", "No", "No", "Yes", "No"), levels = c("Yes", "No"))) 

    > ct   Vote.for.X ote.for.X.Last.Time 1        Yes                 Yes 2        Yes                  No 3         No                  No 4   Not Sure                 Yes 5         No                  No > table(ct)           ote.for.X.Last.Time Vote.for.X Yes No   Yes        1  1   No         0  2   Not Sure   1  0 >

    在数据框ct中,第一行为(yes,yes),第二行为(yes,no),以此类推,table(ct)就是为出现这种情况的统计。

    转载请注明原文地址: https://ju.6miu.com/read-964615.html

    最新回复(0)