我有两个变量想要在直方图中进行比较,如下所示。对于直方图的每个箱,都会显示两个变量的频率,这使得比较它们变得很容易。
最佳答案
您可以使用add
参数到hist
(参见?hist
、?plot.histogram
):
hist(rnorm(1000, mean=0.2, sd=0.1), col='blue', xlim=c(0, 1))
hist(rnorm(1000, mean=0.8, sd=0.1), col='red', add=T)
为了了解 add
参数,我注意到在 ?hist
中 ...
参数表示这些是传递给 plot.histogram
和 add
记录在 ?plot.histogram
中。或者,?hist
底部的示例之一使用 add
参数。
关于r - R中两个变量的直方图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14638788/