R中两个变量的直方图 [英] Histogram of two variables in R

查看:157
本文介绍了R中两个变量的直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在直方图中比较两个变量,如下所示。对于直方图的每个bin,都显示了两个变量的频率,这使得比较它们变得容易。

I have two variables that I want to compare in a histogram like the one below. For each bin of the histogram the frequency of both variables is shown what makes it easy to compare them.

推荐答案

您可以使用 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 参数。

To find out about the add parameter I noticed that in ?hist the ... argument says that these are arguments passed to plot.histogram, and add is documented in ?plot.histogram. Alternatively, one of the examples at the bottom of ?hist uses the add parameter.

这篇关于R中两个变量的直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆