X1- c229451161526478317 histX1 freq = FError in if freq x$counts else x$density the condition has length 1In addition Warning messageIn freq && !equidist lengthx = 9 1 in coercion to logical1 line
这个错误的原因是在画直方图时,参数freq应该设为FALSE而不是F。此外,也需要先调用plot()函数画出画布再画直方图和密度曲线。以下是正确的代码:
X1<- c(22,9,4,5,1,16,15,26,47,8,31,7) plot(density(X1)) hist(X1, freq = FALSE, add = TRUE)
原文地址: https://www.cveoy.top/t/topic/fUum 著作权归作者所有。请勿转载和采集!