2014-03-29 261 views
1

Iam对于R来说比较新,并且无法自己弄清楚。R:如何乘以频率直方图的X轴和Y轴

我有一个频率直方图,我试图将每个箱(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) 

谢谢!

回答

0

试试这个:

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

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