在R中绘制“列”图表类型

在R中绘制“列”图表类型,r,plot,ggplot2,R,Plot,Ggplot2,我有以下data.frame.csv文件: 月数据输入月数据输出月数据输入月数据输出月数据输出 365.506166 404.953832 233.2757866667 277.0273782857 83.6223894415 304.9411340597 83.3290775473 177.251202913 215.805346 261.719192 200.05035336078 266.8439798431 56.2463860296 231.5178528013 49.33544878

我有以下data.frame.csv文件:

月数据输入月数据输出月数据输入月数据输出月数据输出

365.506166 404.953832 233.2757866667 277.0273782857

83.6223894415 304.9411340597 83.3290775473 177.251202913

215.805346 261.719192 200.05035336078 266.8439798431

56.2463860296 231.5178528013 49.3354487884 214.3130820265

141.0012916923198.2611403077145.39269568151.4908766939

872.4538060177 865.5696917647 938.4100522767 941.1982855211

243.5898831429 46.6781673766 219.9683379423 41.7586427475

41.2589185368309.283068307734.0903168571319.34763075

74.2917333287.169803036188.9124322553285.4422067097

66.4870296599 NA 63.1332482997 224.7596242353

NA NA 40.099222175NA

在LibreOffice中,我可以很容易地绘制Column类型的图表。截图是

我一直在尝试使用barplot在R中获得相同的类似图

plot4 <- barplot(as.matrix(plotData),)
到目前为止没有成功

有什么建议吗? 多谢各位

编辑:我想我已经找到了答案

plotData <- do.call(rbind, plotData)
plotThroughput <- barplot(plotData,
                          main="Average Throughput",
                          xlab="Nodes",
                          beside=TRUE,
                          ylab="Throughput (Mbps)",
)
修改了一些小的代码改进。

我在arules包中使用了重塑和ggplot库以及离散化函数

ggplot的优点是,您可以轻松地执行类似的操作,这一点在IMO中要清楚得多

编辑对OP评论的回应

gg <- melt(cbind(id=factor(1:nrow(df)),df),id="id")
gg <- cbind(facet=rep(1:2,each=2*nrow(df)),gg)
ggplot(gg) + 
  geom_bar(aes(x=id,y=value,fill=variable),stat="identity",position="dodge")+
  facet_grid(facet~.)+
  scale_fill_discrete(name="")+
  theme(legend.position="bottom")

条形图和条形图在不同的软件包中是完全不同的图。请相应地更新。感谢您发现它。修正了我的打字错误。我落后了一分钟。。。嘿,想找个时间配对代码吗?这是我需要的。看起来比我的答案好多了。非常感谢,霍华德。我是否需要运行ggplotgg+。。。仅在R控制台中使用命令?我在脚本中运行了它,但没有得到任何结果。将整个过程放在一个调用中以绘制…,或者更常见的是,编写ggp真棒,它成功了!非常感谢。此外,我喜欢您表示我的数据的方式。更容易看到总体情况。这里只有一个问题:有没有可能让monthlyDataIn和monthlyDataOut一起策划,monthlyDataInOut和MonthlyDatoOut一起策划?
#Example data
plotData <- data.frame(structure(replicate(4, runif(50, 50, 200), simplify = FALSE), .Names = cs))
plotData2 <- melt(plotData)
plotData2$value <- arules::discretize(plotData2$value, categories = 5)
ggplot(plotData2, aes(x = value, fill = variable)) + geom_bar(position = 'dodge', binwidth = 30, width = 0.9)
library(ggplt2)
library(reshape2)
df <- read.csv("plotdata.csv")
gg <- melt(cbind(id=factor(1:nrow(df)),df),id="id")
ggplot(gg) + 
  geom_bar(aes(x=id,y=value,fill=variable),stat="identity")+
  facet_grid(variable~.)
gg <- melt(cbind(id=factor(1:nrow(df)),df),id="id")
gg <- cbind(facet=rep(1:2,each=2*nrow(df)),gg)
ggplot(gg) + 
  geom_bar(aes(x=id,y=value,fill=variable),stat="identity",position="dodge")+
  facet_grid(facet~.)+
  scale_fill_discrete(name="")+
  theme(legend.position="bottom")