0

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)
})
Phia-CM
  • 67
  • 1
  • 9
  • 3
    I can run `x<-density(MASS::Boston$tax); plot(x); rug(MASS::Boston$tax)` without error. How is `myBoston` different from the actual `Boston` data set? Please make sure to include a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with data that will trigger the problem. – MrFlick Feb 09 '17 at 23:17
  • it is not different in anyway, also I tried running it without creating a local data frame and the exact same error shows up :/ – Phia-CM Feb 10 '17 at 19:50
  • Are you running in a clean R session? Are these the first commands you run? Are you sure you aren't redefining anything else in your session? Perhaps you could share your `sessionInfo()` to see what version of R you are running. Maybe also show the results of `conflicts(detail=T)` to see if you've over-written any base functions. – MrFlick Feb 10 '17 at 20:19
  • So I am running a clean R session and yes these are my first commands – Phia-CM Feb 10 '17 at 21:56

1 Answers1

0

The error says- plot.new has not been run yet. So before using rug just run plot.new(). Just like that. It removes that part of the error.

Swati
  • 1