在 R 中手动输入意外事件 table
Manually entering contingency table in R
嗨,我在 R 中有以下代码,
> trial <- matrix(c(6,9,6,5,2,2,5,8,5,3,2,4,6,8,8), ncol=5,byrow=T)
> colnames(trial) <- c('Never','Rarely','Sometimes', 'Often' ,'Always')
> rownames(trial) <- c('Walk', 'Bus','Drive')
> trial
Never Rarely Sometimes Often Always
Walk 6 9 6 5 2
Bus 2 5 8 5 3
Drive 2 4 6 8 8
然而我想要的是;
Breakfast Never Rarely Sometimes Often Always
Travel
Walk 6 9 6 5 2
Bus 2 5 8 5 3
Drive 2 4 6 8 8
即突发事件 table,其中 Breakfast 有 Never、Rarely 等选项。
旅行有步行、公共汽车等选项。
谢谢
礼貌回答:Salvatore S. Mangiafico,Ph.D。
trial <- matrix(c(6,9,6,5,2,2,5,8,5,3,2,4,6,8,8), ncol=5,byrow=T)
colnames(trial) <- c('Never','Rarely','Sometimes', 'Often' ,'Always')
rownames(trial) <- c('Walk', 'Bus','Drive')
Trial = as.table(trial)
dimnames(Trial)
names(dimnames(Trial)) = c("Transport", "Breakfast")
嗨,我在 R 中有以下代码,
> trial <- matrix(c(6,9,6,5,2,2,5,8,5,3,2,4,6,8,8), ncol=5,byrow=T)
> colnames(trial) <- c('Never','Rarely','Sometimes', 'Often' ,'Always')
> rownames(trial) <- c('Walk', 'Bus','Drive')
> trial
Never Rarely Sometimes Often Always
Walk 6 9 6 5 2
Bus 2 5 8 5 3
Drive 2 4 6 8 8
然而我想要的是;
Breakfast Never Rarely Sometimes Often Always
Travel
Walk 6 9 6 5 2
Bus 2 5 8 5 3
Drive 2 4 6 8 8
即突发事件 table,其中 Breakfast 有 Never、Rarely 等选项。 旅行有步行、公共汽车等选项。 谢谢
礼貌回答:Salvatore S. Mangiafico,Ph.D。
trial <- matrix(c(6,9,6,5,2,2,5,8,5,3,2,4,6,8,8), ncol=5,byrow=T)
colnames(trial) <- c('Never','Rarely','Sometimes', 'Often' ,'Always')
rownames(trial) <- c('Walk', 'Bus','Drive')
Trial = as.table(trial)
dimnames(Trial)
names(dimnames(Trial)) = c("Transport", "Breakfast")