How to check if a correlation exists between a continuous independent and a binary dependent variable So this has been a headache for me. None of the resources I found could explain it in a manner I understand.
Having two sets of data:
x <- c(2, 4, 5, 6, 7, 8, 9, 9, 4, 5)
y <- c(0, 1, 0, 0, 0, 1, 1, 0, 1, 0)
df <- data.frame(x, y)

The y variable is binary and the x variable is continuous as you can see.
What I understand so far is that some machine learning models, like logistic regression, expect the log odds of the y variable to have a linear relationship with the y variable.
How would I make a plot that shows if they abide to this assumption or not and how would I read that plot? I prefer examples in R but any explanation you feel might contribute to my understanding is more than welcome.
 A: One way to look at the data:
x <- c(2, 4, 5, 6, 7, 8, 9, 9, 4, 5)
y <- c(0, 1, 0, 0, 0, 1, 1, 0, 1, 0)

stripchart(x ~ y, meth="stack", ylim=c(.5,2.5), pch=19)
  abline(h=1.5, col="green2")


From the stripcharts, we can see that the data values for the two groups are not much different. If integer values given in x are rounded continuous variables, then a 2-sample t-test would be
appropriate, but with so much overlap between values for the
two groups, I would not expect significance. Output from running this test in R shows a P-value greater than 5%, so the two sample means, 5.67 and  6.25, 
are not significantly different from each other.
t.test(x ~ y)

        Welch Two Sample t-test

data:  x by y
t = -0.359, df = 5.9956, p-value = 0.7319
alternative hypothesis: 
   true difference in means is not equal to 0
95 percent confidence interval:
 -4.560011  3.393344
sample estimates:
mean in group 0 mean in group 1 
       5.666667        6.250000 

Here are somewhat similar data for which there is a highly significant difference between groups.
stripchart(x1 ~ y, meth="stack", ylim=c(.5,2.5), pch=19)
  abline(h=1.5, col="green2")


t.test(x1 ~ y)

        Welch Two Sample t-test

data:  x1 by y
t = -5.2824, df = 5.9956, p-value = 0.001865
alternative hypothesis: 
   true difference in means is not equal to 0
95 percent confidence interval:
  -12.560011  -4.606656
sample estimates:
mean in group 0 mean in group 1 
       5.666667       14.250000 

