我正在使用R中的波士顿数据集并试图用它绘制地毯我得到以下错误代码
s <- density(myBoston$tax)
plot(s)
rug(myBoston$tax)
但是,这是出现的错误:
some values will be clipped
Hide Traceback
Error in axis(side = side, at = at, labels = labels, ...) : plot.new has not been called yet
4.
axis(side = side, at = at, labels = labels, ...)
3.
Axis.default(side = side, at = x, labels = FALSE, lwd = 0, lwd.ticks = lwd, col.ticks = col, tck = ticksize, ...)
2.
Axis(side = side, at = x, labels = FALSE, lwd = 0, lwd.ticks = lwd, col.ticks = col, tck = ticksize, ...)
1.
rug(myBoston$tax)
我还没有以任何方式操纵数据,我试着阅读 ?地毯() 看看我做错了什么,但根本没有帮助。有什么建议吗?
编辑:
这是我在运行时获得的
sessioninfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] MASS_7.3-45 ggplot2_2.2.1 dplyr_0.5.0 alr4_1.0.5 effects_3.1-2 car_2.1-4
另一个编辑:
这个代码工作但是为什么不是原始
with(Boston, {
plot(density(tax))
rug(tax)
})
答案 0 :(得分:0)
错误说-plot.new尚未运行。因此,在使用rug之前,只需运行 plot.new()。就这样它将消除该部分错误。