开始使用免费开始使用

三种分箱宽度

在习惯使用这些图形之前,建议先看看当您更改分箱宽度时会发生什么。分箱宽度决定分布看起来有多平滑:分箱宽度越小,分布就越锯齿。为了发现数据中的不同结构,考虑多种分箱宽度是一个良好实践。

本练习是课程的一部分

R 中的探索性数据分析

查看课程

练习说明

请创建下列 3 个图,并在每个图中添加标题以标明所用的分箱宽度:

  • 一个马力(即 horsepwr)的直方图,binwidth 为 3。
  • 第二个马力直方图,binwidth 为 30。
  • 第三个马力直方图,binwidth 为 60。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Create hist of horsepwr with binwidth of 3
cars %>%
  ggplot(aes(___)) +
  geom_histogram(binwidth = ___) +
  ggtitle(___)

# Create hist of horsepwr with binwidth of 30


# Create hist of horsepwr with binwidth of 60

编辑并运行代码