ale*_*lex 10 plot r data-visualization histogram
我有两个变量,我想在直方图中比较,如下所示.对于直方图的每个区间,显示两个变量的频率,以便于比较它们.
mat*_*fee 12
您可以使用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)
Run Code Online (Sandbox Code Playgroud)
要了解关于add
我注意到,在参数?hist
的...
论点说,这些都传递给参数plot.histogram
,并add
在被记录在案?plot.histogram
.或者,底部的一个示例?hist
使用add
参数.
你可以使用prop.table
并barplot
喜欢这个
somkes <- sample(c('Y','N'),10,replace=T)
amount <- sample (c(1,2,3),10,replace=T)
barplot(prop.table(table(somkes,amount)),beside=T)
Run Code Online (Sandbox Code Playgroud)