【问题标题】:R: How to multiply X and Y axis of frequency histogramR:如何将频率直方图的 X 轴和 Y 轴相乘
【发布时间】:2014-05-09 02:58:09
【问题描述】:

我对 R 比较陌生,自己无法弄清楚。

我有一个频率直方图,我试图将每个 bin(Y 轴)的频率与 X 轴上的值相乘。

我的直方图代码如下所示:

logarea <- log10(wildfires$areacalc)  #to make x-axis logarithmic
hist(logarea, breaks="FD", main="Frequency of Fire Size", xlab="Log10 of Area Burned [m2]",
yaxt="n",xlim=c(5,10), cex.main=0.8, cex.axis=0.8, cex.lab=0.75, col="grey47", border = "seashell3")
axis(2, at=seq(0, 1100, by = 200), las = 2, cex.axis=0.8)

谢谢!

【问题讨论】:

    标签: r histogram frequency


    【解决方案1】:

    试试这个:

    h <- hist(logarea,breaks="FD")
    product <- with(h,mids*counts)
    

    除了绘制直方图之外,hist(...) 还返回一个值列表。 h$counts 是每个 bin 中的频率(观察次数),h$mid 是 bin 的中点值。所以我认为这就是你要找的。请参阅documentation 了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-11
      • 2015-10-13
      • 2021-03-03
      • 2015-10-11
      • 2015-08-27
      • 1970-01-01
      • 2012-06-08
      相关资源
      最近更新 更多