I would like to create a data frame like this:
Label Jim Charles Kevin Alan
Charles 0 1 0 0
Kevin 0 0 1 0
Alan 0 0 0 1
Alan 0 0 0 1
Jim 1 0 0 0
I am starting with a data frame where the column names are set and the people’s names are listed in the first column, but all the numbers are 0. I want to quickly be able to set some of them to 1 by matching the name listed in the first column to the column name.
Similar to Ben’s answer, if you’re data is in a data.frame called
df: