I have this df:
>df
author author_id other_authors other_authors_id
A 123 D, E ,F 011 , 021, 003
B 122 G 111
C 121 H, F 101, 003
the last two columns have values stored as list
. I would like to make it from wide to long, but i'm not sure what's the best way to do it. I'm trying to create a network graph from it.
I want to gather them so they look like this:
author other_autors author_id other_autors_id
A D 123 011
A E 123 021
A F 123 003
B G 122 111
C H 121 101
C F 121 003
any ideas how to do it?
I've managed to do this, but it only works if the values are not lists
.
gather(df, key="author", value="other_authors", -author)