假设我有10个观察到1到10之间的200个整数点:
mysample = sample(rep(seq(1,10),20),10);
Run Code Online (Sandbox Code Playgroud)
而且我想要画吧
barplot(table(mysample));
Run Code Online (Sandbox Code Playgroud)
在这个例子中,没有观察7.是否有一种快速的方法告诉barplot将x轴范围设置为1到10之间的所有整数,还是我必须手动编辑表?
MrF*_*ick 11
尝试
barplot(table(factor(mysample, levels=1:10)));
Run Code Online (Sandbox Code Playgroud)
通过使用因子,R将知道哪些级别"缺失"