【问题标题】:R: Histogram is showing Density instead of Frequency [closed]R:直方图显示的是密度而不是频率[关闭]
【发布时间】:2012-09-21 19:25:56
【问题描述】:

我目前正在使用 Twitters API 创建个人推文的直方图。当用户发推文时,我创建一个日期列表(在 for 循环中)。

dates=c(dates,obtweets[[i]]$getCreated());

日期示例:

> dates[1:3]
[1] "2012-09-09 16:01:18 EDT" "2012-09-29 17:26:12 EDT"
[3] "2012-09-28 17:53:34 EDT"

但是,当我生成 hist(dates,breaks=7) 时,它会在 y 轴上显示密度而不是频率。

知道如何显示频率而不是密度吗?

【问题讨论】:

标签: r histogram


【解决方案1】:

来自?hist 文档:

freq: logical; if ‘TRUE’, the histogram graphic is a representation
      of frequencies, the ‘counts’ component of the result; if
      ‘FALSE’, probability densities, component ‘density’, are
      plotted (so that the histogram has a total area of one).
      Defaults to ‘TRUE’ _if and only if_ ‘breaks’ are equidistant
      (and ‘probability’ is not specified).

所以你应该试试hist(dates, breaks = 7, freq = TRUE)

【讨论】:

    猜你喜欢
    • 2015-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-08
    • 2015-07-18
    • 1970-01-01
    • 2012-11-16
    相关资源
    最近更新 更多