我有如下矩阵数据:
df <- matrix(c(18, 54, 33, 75, 24, 15, 23, 15, 8), nrow=3, byrow=T)
dimnames(df) <- list(c('a', 'b', 'c'), c('low', 'moderate', 'high'))
names(dimnames(df))<-c("medicine", "level")
prop.table(df)
prop.table(df, 1)
prop.table(df, 2)
输出:
low moderate high
a 0.06792453 0.20377358 0.12452830
b 0.28301887 0.09056604 0.05660377
c 0.08679245 0.05660377 0.03018868
low moderate high
a 0.1714286 0.5142857 0.3142857
b 0.6578947 0.2105263 0.1315789
c 0.5000000 0.3260870 0.1739130
low moderate high
a 0.1551724 0.5806452 0.5892857
b 0.6465517 0.2580645 0.2678571
c 0.1982759 0.1612903 0.1428571
如何在R中正确绘制这些比例数据?感谢您的帮助。