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

How to create pair of vector that are complementary to each other based on source vector in R

$
0
0

I have the following source vector:

source_vec <- c(1:3)

What I want to do is to enumerate the vector by splitting into two when one value is selected the other vector is complementary. Finally, it'll look like this (do by hand):

  from  to
  1,2    3
  1,3    2
  2,3    1

Note that the to column only one value, but from can be many.

Ideally, the final output is a dataframe/tibble, but from column is a list column.

How can I achieve that with R?


Viewing all articles
Browse latest Browse all 201839

Trending Articles



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