# R - convert factor() column into a Binary Matrix Value

I am quite new to R, and I need R to recognize some of data as binary. So I made a survey and I'd like R to analyze the Gender, Like, and Share columns as binary - so I can ggplot them properly.

``head(d)Gender Age Like Share1 Male 26 No 22 Male 23 Yes 03 Female 21 No 44 Male 19 No 05 Female 20 Yes 06 Male 23 No 4``

The thing is that I would like to evaluate if there's a corrolation between certain factors - and to do so, I want to do a regression line that would look like this. But the problem is that I always get this error message

``M <- ggplot(data=d,aes(x=Age,colour=Share) + geom_point())Error in aes(x = Age, colour = Share) + geom_point() :non-numeric argument to binary operator``

So if you could help me out with those two problems, that'd be awesome.

One last thing, I don't know if this could help, but in case, I'll give it to you ...

`` sapply(D,class)Gender Age Like Share"integer" "numeric" "integer" "integer"sapply(D,mode)Gender Age Like Share"numeric" "numeric" "numeric" "numeric"``

Thanks a lot in advance !

The easiest way to make those categories binary would be something like this:

``````d\$GenderBinary <- 0
d\$GenderBinary[d\$Gender == "Male"] <- 1
d\$LikeBinary <- 0
d\$LikeBinary[d\$Gender == "Yes"] <- 1
``````

Not sure how you expect to make a column with more than two categories binary, though ("Share").

For the ggplot error, it looks like you have forgotten to supply the y variable(s) (which presumably would be your binary variables).