Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205491

Create dataframe of all combinations of a list

$
0
0

I have dataframe of integers from 1 to 900.

nodelist <- data.frame(node_id=seq(1:900))

I want to create a new dataframe of two columns (top, bottom) that has each combination of the vector nodelist. The top and bottom number cannot be the same. Something like:

top   bottom
1     2
1     3
1     4
2     1
2     3

I have tried cross() and expand.grid() to no avail.


Viewing all articles
Browse latest Browse all 205491

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>