I'm using R (with RStudio) to solve a little classification problem. This is my problem: I have this dataset (the image represents the content of the window 'Environment' of RStudio):
As you can see, I have the dataset c.data that includes 3 variables (2 of these have type Factor with 2 levels: 0 and 1).
I want to do a plot to plot the variable mpg
as x and vs
as y.I give R the following command:
> plot(c.data$mpg, c.data$vs)
And this is the result:
I don't understand why the values associated with the variable vs
are set automatically by R as values having "1.0" or "2.0" (I'm fine with them being displayed this way, as a binary variable, but I don't understand why if they assume "0" or "1" as values they should be put in the graph in the wrong values 1 and 2). In this way if I try to plot the line of logistic regression I get a very bad thing:
Why this thing happening? How can I have the REAL values of vs
on the y axis (ie 0.0 and 1.0) in order to plot a coherent (logistic) line?