【发布时间】:2015-06-20 14:08:10
【问题描述】:
想用我的数据在这里复制它
Plot histograms over factor variables
我的数据是这样的
2 -11.0 0
2 -10.8 0
2 -10.6 0
2 -10.4 0
2 -10.2 0
完整的数据框在这里https://www.dropbox.com/s/r616tyr17q40x6g/t4.RData?dl=0
第一列是直方图编号,接下来是 bin,最后是每个 vi bin 的计数。与原始示例一样(工作日、小时数、计数)。
我还考虑列 - 因为我没有字符串,我只是这样做
as.factor(df[,3])-.df[,3]
asfactor(df[,2])->df[,2]
每个直方图的 bin 都相同。直方图 1 到 1598 都有 60 个 bin,范围从 -11 到 plus 2 x 0.2。这是在第 2 列。具体计数在第 3 列,而 ind 在第 1 列。
然后我做
p<-ggplot(data=t4, aes(x=V2))
p<-p+geom_histogram(aes(weights=V3))
p<-p+facet_wrap(~V1,ncol=1)
当我绘制 p 时,我得到了
Error in Summary.factor(structure(1L, .Label = c("0", "1", "2", "3", "4", :
sum not meaningful for factors
对于每个直方图。
为什么会出现这个错误>
我如何也摆脱代码中绘制的每个直方图的大标题 - 在我的情况下,它看起来像这样 http://postimg.org/image/4yhvz9i67/
【问题讨论】: