I'm wanting to run a network analysis but am completely lost at how to get my data structured correctly, since most examples already have data structured at the to
and from
level.
An example of my data looks like:
df <- data.frame(Name = c("Alice", "Ben", "Tom", "Jane", "Neil", "Alice", "Tom", "Ben", "Jane", "Neil", "Alice", "Tom", "Ben", "Jane", "Bob"),
Location = c("Ward", "Desk", "Op", "Call", "Off",
"Ward", "Desk", "Op", "Call", "Off",
"Ward", "Desk", "Op", "Call", "Off"),
Rating = c(1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 8, 8, 8, 8, 8))
I now wish to get to
and from
combinations of people, as denoted by Name
, for every Rating
. You will also note that people can be at a different Location
during a different rating, although I'd prefer to for this, in combination with Name
to be the nodes and Rating
to be the edges.
I have looked at library(iterpc)
but am struggling to comprehend the whole combination thing, with five different lineups.
Is there a potential dplyr
solution to my problem? Thank you!
EDIT: It looks as though my question is very similar to this yet the answer marked does not work for me, instead I get Error: Column name Name must not be duplicated.