# R - Analyzing Relationship Between Two (or more) Binary Variables

Say I have two vectors:

Action.Taken = c(0,1,0,0,1,1,0,1,0)
Success = c(0,0,0,1,0,1,0,1,0)


The first tells me whether or not a specific action was taken in a trial and the second tells me whether or not that trial succeeded. How would I go analyzing these two vectors to answer the following question: Does taking action (Action.Taken = 1) affect whether or not success is had (Success = 1)? I'd like some measure of significance as an regression/hypothesis testing.

I'm looking for an answer that I can implement using R. I am also quite new to stats, so it would be nice if someone could give me a relatively simple, straightforward answer/example.

Thanks!

• Consider the chi-square test for independence. Jul 14, 2014 at 21:37
• And the correlation coefficient (phi) that can be computed based on Chi-Square. Jul 14, 2014 at 21:45
• Yeah, I've actually tried the prop.test function, which returns, among other things, the p-value given the null hypothesis that two (or more) proportions aren't different. I think phi is just as simple as cor(dat), but I don't know what/how much that tells me. Jul 14, 2014 at 21:51

contingency = table(Action.Taken, Success)

chisq.test(contingency)