我使用ggplot为我拥有的一组数据制作了一个条形图图(使用7点利克特量表测量脉冲宽度和频率上的紧迫性,烦恼,价和唤醒水平)。分组基于我需要的数据集中的变量
我使用的代码如下:
breaks = c(1,2,3,4,5,6,7)
labels = as.character(breaks)
breaks2 = c(10, 30, 50, 70, 90, 110)
labels2 = as.character(breaks2)
BarChart_Freq_Dvs = ggplot(AllResults, aes(Frequency, value, group = variable,
shape = variable, linetype=variable, fill = variable))
BarChart_Freq_Dvs +
stat_summary(fun.y = mean, geom = "bar", width = 9, position = position_dodge(width = 11))+
stat_summary(fun.data = mean_cl_normal, geom = "errorbar", width = 7, position = position_dodge(width
= 11))+
scale_y_continuous(name = "likert scale",
limits = c(1,7), breaks = breaks, labels = labels, oob = rescale_none)+
scale_x_continuous(name = "Frequency",
limits = c(10,110), breaks = breaks2, labels = labels2, oob = rescale_none, expand
= c(0.06,0))+
theme_classic()+
theme(panel.background = element_rect(fill = NA),
panel.grid.major.y = element_line(colour = "grey50"),
panel.ontop = TRUE)
然后我决定将条形图替换为箱形图并写道:
Box_Plot = ggplot(AllResults, aes(Frequency, value, group = variable,
shape = variable, linetype=variable, fill = variable))
Box_Plot +
geom_boxplot() +
scale_y_continuous(name = "likert scale", limits = c(1,7), breaks = breaks, labels = labels, oob =
rescale_none)+
scale_x_continuous(name = "Frequency",
limits = c(10,110), breaks = breaks2, labels = labels2, oob = rescale_none,
expand = c(0.06,0))+
theme_classic()+
theme(panel.background = element_rect(fill = NA),
panel.grid.major.y = element_line(colour = "grey50"),
panel.ontop = TRUE)
但是我得到了下面的图,它确实有意义
我在互联网上搜索了一个修复程序,发现的所有代码几乎与我编写的代码相同。我不知道我的代码在哪里。
样本:
PW Frequency variable value
High 110 urgency 3
Middle 10 urgency 2
Low 70 urgency 2
High 30 urgency 5
Middle 50 urgency 3
Low 70 annoyance 5
Middle 50 annoyance 4
High 90 annoyance 7
Middle 90 annoyance 5
High 110 annoyance 7
High 10 annoyance 2
High 50 valence 3
Middle 10 valence 4
Low 50 valence 4
Middle 50 valence 4
Low 30 valence 4
Middle 30 valence 4
High 90 arousal 4
Middle 110 arousal 3
High 70 arousal 3
Middle 70 arousal 2
Middle 90 arousal 2
Low 10 arousal 1