Gre*_*now 25
使用基本图形,您可以这样做:
mydf <- data.frame( X1=c(A=2, B=4, C=1), X2=c(3,2,NA), X3=c(4,1,NA) )
barplot(t(as.matrix(mydf)), beside=TRUE)
Run Code Online (Sandbox Code Playgroud)
使用额外的调用axis可以使标签更像问题.
Bea*_*eld 17
假设您不想要ascii输出,这里有一个解决方案ggplot2:
# load / generate your data
mydf <- data.frame( X1 = c(2,4,1), X2 = c(3,2,NA), x3 = c(4,1,NA), row.names=c("A","B","C") )
mydf$Category <- row.names(mydf)
# bring your data to long format as needed by ggplot
library(reshape2)
mydf.molten <- melt(mydf, value.name="Count", variable.name="Variable", na.rm=TRUE)
# plot and facet by categories
library(ggplot2)
qplot( data=mydf.molten, x = Variable, y = Count, geom="bar", stat = "identity" ) + facet_wrap( "Category" )
Run Code Online (Sandbox Code Playgroud)

有关详细信息,我建议您参考ggplot2手册,尤其是关于geom_bar和的章节facet_wrap.
| 归档时间: |
|
| 查看次数: |
41562 次 |
| 最近记录: |