Create a binary indicator matrix in R

Posted by Brian Vanover on Stack Overflow See other posts from Stack Overflow or by Brian Vanover
Published on 2013-07-02T17:00:33Z Indexed on 2013/07/02 17:05 UTC
Read the original article Hit count: 344

I have a list of data indicating attendance to conferences like this:

Event Participant
ConferenceA John
ConferenceA Joe
ConferenceA Mary
ConferenceB John
ConferenceB Ted
ConferenceC Jessica

I would like to create a binary indicator attendance matrix of the following format:

Event John Joe Mary Ted Jessica
ConferenceA 1 1 1 0 0
ConferenceB 1 0 0 1 0
ConferenceC 0 0 0 0 1

Is there a way to do this in R? Sorry for the poor formatting.

© Stack Overflow or respective owner

Related posts about r

    Related posts about matrix