I would like to manipulate data to do network analysis using ggnet.
The dataset is in csv form and looks like this:
offers
{9425, 5801, 18451, 17958, 16023, 7166}
{20003, 17737, 4031, 5554}
{19764, 5553, 5554}
What I would like to break the array, and iterate to permute all the items each row as a pair of 2. So the ultimate output should look like:
print list(itertools.permutations([1,2,3,4], 2)) per row to create:
(9425, 5801)
(9425, 18451)
(9425, 17958)
(9425, 16023)
(9425, 7166)
(5801, 18451)
(5801, 17958)
(5801, 16023)
(5801, 7166)
...
I could use either R or Python to do this. Any suggestions to solve this problem?
See Question&Answers more detail:os