【发布时间】:2019-11-20 13:05:11
【问题描述】:
我想制作我的数据集第 5-34 列的直方图并保存以供参考。这就是我所拥有的,并且不断出现错误“x 必须是数字”。所有这些列都有数字数据。
[数据截图][1]
dput(longbroca)
histograms = c()
GBhistograms = c()
RThistograms = c()
for (i in 5:34){
hist(longbroca)
hist(GBlongbroca)
hist(RTlongbroca)
histograms = c(histograms, hist(longbroca[,5:34]))
GBhistograms = c(GBhistograms, hist(GBlongbroca[,5:34]))
RThistograms = c(RThistograms, hist(RTlongbroca[,5:34]))
}
#reproducible
fakerow1 <- c(100,80,60,40,20)
fakerow2 <- c(100,80,60,40,20)
fakedata = rbind(fakerow1,fakerow2)
colnames(fakedata) = c('ant1','ant2','ant3','ant4','ant5')
【问题讨论】:
-
您能否通过
dput()函数分享您的数据样本? -
您没有使用
i来引用特定列。你的意思是hist(longbroca[,i])等等? -
添加了数据样本,我添加了
hist(longbroca[,i]),我得到了同样的错误 -
通常人们将 dput() 的控制台输出复制到代码块中。或者将一些模拟数据放入代码块中。