-1

I have some data on a xlsx file I had succesfully put on a frequency table and the breakspoints were configured correctly with Sturges.

number_observations = length(data)
classes = factor(cut(data, breaks=nclass.Sturges(data)))
tabulation = as.data.frame(table(classes))
tabulation = transform(tabulacion, cumFreq = cumsum(Freq), relative = prop.table(Freq), cumRelative = cumsum(prop.table(Freq)))

% Tabulation display
    clases      Freq   cumFreq   relative   cumRelative
1    (195,262]  xxx    xxxx      x.xxxxxxx  x.xxxxxxx
2    (262,329]  yyy    yyyy      y.yyyyyyy  y.yyyyyyy
3    (329,396]  zzz    zzzz      z.zzzzzzz  z.zzzzzzz

Now, I need to do a histogram with the same breakpoints, but the problem is that the histogram generated doesn't make the breakpoints correctly, meaning, first, that the maximun and minimun of the data are being presented incorrectly, and second, that the histogram has more classes than the frequency table. For case of this problem, I expect the histogram has 12 classes, but for unknown reasons for me, it makes more.

Any suggestions, and/or idea what I'm doing wrong?

4

1 回答 1

0

我没有把注意力放在这个问题上,所以,我找到了一个解决方案,部分基于这个:如何使用'arrange'命令为 R 中的直方图生成一组箱,假设我有我的数字向量中的数据。

实际上的问题是“如何正确设置直方图的 bin”,直方图的 bin 将代表每个类,所以我使用了数据的最小值和最大值,以及类的范围

bins = seq(min(data), max(data), by=range)

然后给出箱的数量作为直方图中断的参数。

hist(data, freq=TRUE, breaks=bins)
于 2013-10-30T21:20:07.173 回答