Getting frequency values from histogram in R

后端 未结 3 595
误落风尘
误落风尘 2020-12-13 00:18

I know how to draw histograms or other frequency/percentage related tables. But now I want to know, how can I get those frequency values in a table to use after the fact.

3条回答
  •  自闭症患者
    2020-12-13 00:39

    From ?hist: Value

    an object of class "histogram" which is a list with components:

    • breaks the n+1 cell boundaries (= breaks if that was a vector). These are the nominal breaks, not with the boundary fuzz.
    • counts n integers; for each cell, the number of x[] inside.
    • density values f^(x[i]), as estimated density values. If all(diff(breaks) == 1), they are the relative frequencies counts/n and in general satisfy sum[i; f^(x[i]) (b[i+1]-b[i])] = 1, where b[i] = breaks[i].
    • intensities same as density. Deprecated, but retained for compatibility.
    • mids the n cell midpoints.
    • xname a character string with the actual x argument name.
    • equidist logical, indicating if the distances between breaks are all the same.

    breaks and density provide just about all you need:

    histrv<-hist(x)
    histrv$breaks
    histrv$density
    

提交回复
热议问题