假设您阅读了变量中的 2 个文件data1
,data2
您可以执行以下操作:
bins <- seq(0, 100, 5) # Change this to whatever range your data encopasses
h1 <- hist(data1, bins, plot=0)
h2 <- hist(data2, bins, plot=0)
ratio <- h1$counts/h2$counts
# Remove NaNs and Infs due to 0 counts
ratio[is.na(ratio)] <- 0
ratio[is.inf(ratio)] <- 0
barplot(ratio)
Run Code Online (Sandbox Code Playgroud)
或者,您可以创建第三个 hist 对象,其优点是可以正确绘制 x 轴
h3 <- h1
h3$counts <- ratio
plot(h3, col="black")
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1649 次 |
最近记录: |