我正在尝试使用 ggplot2 绘制箱线图。样本数据是这样的。
> sampe
count genotype
71 mt
50 mt
71 mt
95 wt
60 mt
63 mt
75 mt
82 wt
93 wt
87 wt
61 mt
102 wt
60 mt
78 wt
78 wt
87 wt
84 wt
104 wt
81 wt
85 mt
> qplot(factor(genotype),count,data=sampe,geom="boxplot")
Run Code Online (Sandbox Code Playgroud)
上面的命令产生这样的情节:

这里怎么了??为什么会这样??即使是下面的代码也会产生相同的输出。
ggplot(sampe,aes(x=factor(genotype),y=count))+geom_boxplot()
Run Code Online (Sandbox Code Playgroud)
好的..我会回答我自己的问题。根据建议,计数值存储为因子。将它们转换为数字就成功了
qplot(factor(genotype),as.numeric(count),data=sampe,geom="boxplot")
Run Code Online (Sandbox Code Playgroud)
谢谢大家的建议。