gpt4 book ai didi

r - R中直方图中条形的中心值

转载 作者:行者123 更新时间:2023-12-04 05:40:20 25 4
gpt4 key购买 nike

希望在 R 中的条形中心绘制 x 轴的值。

遇到问题,找到使这成为可能的方法,代码如下:

hist(sample_avg, breaks =7, ylim=c(0,2000), 
main = 'Histogram of Sample Average for 1 Coin Flip', xlab= 'Sample Average')

这只是为了抛硬币,所以我有 6 个可能的值,并且想要有 6 个桶,每个桶下面都有 x 轴刻度线。

任何帮助深表感谢。

最佳答案

hist()返回 mids 中条形中点的 x 坐标组件,所以你可以这样做:

sample_avg <- sample(size=10000,x=seq(1,6),replace=TRUE)
foo <- hist(sample_avg, breaks =7, ylim=c(0,2000),
main = 'Histogram of Sample Average for 1 Coin Flip', xlab= 'Sample Average',
xaxt="n")
axis(side=1,at=foo$mids,labels=seq(1,5))

关于r - R中直方图中条形的中心值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13461837/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com