我尽力阅读与我的问题相关的问题。最相关的是:question。但是我无法弄清楚如何解决我的问题。我有一个像
structure(list(COMPANY = structure(1:5, .Label = c("Architecten",
" 2.0", " Adema", "B.V.",
" Alex"), class = "factor"), `YOUR COMPANY PERFORMANCE ORIENTATION` = c(5,
7, 6, 4.5, 4.5), `AVERAGE PERFORMANCE ORIENTATION` = c(5.17,
5.17, 5.17, 5.17, 5.17), `YOUR COMPANY LEARNING ORIENTATION` = c(5,
5.6, 5.8, 6.2, 3.8), `AVERAGE LEARNING ORIENTATION` = c(5.67, 5.67, 5.67, 5.67, 5.67)), .Names = c("COMPANY", "YOUR COMPANY PERFORMANCE ORIENTATION",
"AVERAGE PERFORMANCE ORIENTATION", "YOUR COMPANY LEARNING ORIENTATION",
"AVERAGE LEARNING ORIENTATION"), class = "data.frame", row.names = c(NA,
5L))
通过使用melt(来自库reshape2)我能够获得:
structure(list(COMPANY = structure(c(1L, 2L, 3L, 4L, 5L, 1L,
+ 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), class = "factor", .Label = c("Architecten",
" 2.0", " Adema", "B.V.",
" Alex")), variable = structure(c(1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L,
4L, 4L), .Label = c("YOUR COMPANY PERFORMANCE ORIENTATION", "AVERAGE PERFORMANCE ORIENTATION",
"YOUR COMPANY LEARNING ORIENTATION", "AVERAGE LEARNING ORIENTATION"
), class = "factor"), value = c(5, 7, 6, 4.5, 4.5, 5.17, 5.17,
5.17, 5.17, 5.17, 5, 5.6, 5.8, 6.2, 3.8, 5.67, 5.67, 5.67, 5.67,
5.67)), .Names = c("COMPANY", "variable", "value"), row.names = c(NA,
-20L), class = "data.frame")
通过使用以下代码,我能够并排绘制平均值和公司变量:
plot_try <-ggplot(mydataset,aes(COMPANY,value,fill=variable))+
geom_bar(stat="identity",position="dodge")+ theme(axis.ticks = element_blank(), axis.text.x = element_blank())+ facet_wrap(~COMPANY)
我想在前两个栏(“您的公司绩效导向”和“平均绩效导向”)和最后两个栏之间添加空间,但我无法做到这一点。关于将什么添加到我的代码中的任何建议?谢谢。