How to avoid “Error in stripchart.default(x1, …) : invalid plotting method” error?

The issue is because plot() is looking for vectors, and you’re feeding it one data.frame and one vector. Below is an illustration of some of your options.

mydata <- seq(1,5) # generate some data
sq <- seq(1,5)

plot(sq, mydata) # Happy (two vectors)

x <- data.frame(sq) # Put x into data.frame

plot(x, mydata) # Unhappy (one data.frame, one vector) (using x$seq works)
##Error in stripchart.default(x1, ...) : invalid plotting method

x2 <- data.frame(sq, mydata) # Put them in the same data.frame

##x2
##  sq mydata
##1  1      1
##2  2      2
##3  3      3
##4  4      4
##5  5      5

plot(x2) # Happy (uses plot.data.frame)

Leave a Comment