HAVE
is a data frame with this structure:
name workplace pr_happy
a A 0.93
b B 0.54
c A 0.72
d C 0.17
e D 0.44
I WANT
to build an adjacency matrix of name and workplace (exactly like this question: converting data frame into affiliation network in R), but instead of a matrix with binary values, I want the values of pr_happy
to populate the cells for each affiliation. WANT
should look like this:
A B C D
a 0.93 0.00 0.00 0.00
b 0.00 0.54 0.00 0.00
c 0.72 0.00 0.00 0.00
d 0.00 0.00 0.17 0.00
e 0.00 0.00 0.00 0.44
I'm having a hard time wrapping my head around a way to do this simply. Any thoughts?