I am using the Boston data set in R and trying to plot a rug with it I get the following error code
s <- density(myBoston$tax)
plot(s)
rug(myBoston$tax)
However, this is the error that shows up:
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)
I haven't manipulated the data in any way and I tried read the ?rug() To see what I am doing wrong but that has not helped at all. Any advice?
EDITS:
This is what I get when running
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
ANOTHER EDIT:
THIS CODE WORKS BUT WHY NOT THE ORGINAL
with(Boston, {
plot(density(tax))
rug(tax)
})