How to avoid the error "Error in the stripchart.default (x1, ...) file: invalid plotting method"?

I have a simple, single test.txt data file that contains:

 1 5 7 9 11 

I want to build this file with index numbers. I tried the following:

 mydata<-read.table("test.txt") sq<-seq(1,5) x<-data.frame(sq) plot(x,mydata) 

But the plot is not generated. Instead, an error message is displayed:

Error in stripchart.default (x1, ...): invalid plotting method

Can you indicate what I am doing wrong, or suggest a better solution?

+5
source share
1 answer

The problem is that plot() looking for vectors, and you feed it with one data.frame file 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) 
+7
source

Source: https://habr.com/ru/post/1214844/


All Articles