title: Distributing a list of values into a matrix without a value being repeated within a Row or within a Column using R
body: <p>I have a list of compound ids and masses and I want to distribute the compounds and masses into individual dataframes without more than one compound with the same mass appearing within a column or a row as shown in the image below.</p>
  <pre><code>dfx &lt;- data.frame(id = c(&quot;A_0401923-001-AA&quot;, &quot;A_0401924-001-AA&quot;, &quot;A_0401925-001-CF&quot;, &quot;A_0402137-001-AA&quot;, &quot;A_0402138-001-AA&quot;, &quot;A_0402139-001-AA&quot;, &quot;A_0402140-001-AA&quot;, &quot;A_0402141-001-AA&quot;, &quot;A_0402142-001-CF&quot;, &quot;A_0402158-001-CN&quot;, &quot;A_0402159-001-CN&quot;, &quot;A_0403516-001-AA&quot;, &quot;A_0403517-001-AA&quot;, &quot;A_0403518-001-CF&quot;, &quot;A_0403522-001-AA&quot;, &quot;A_0403523-001-AA&quot;, &quot;A_0403784-001-AA&quot;, &quot;A_0403785-001-CF&quot;, &quot;A_0403786-001-CF&quot;, &quot;A_0403787-001-CF&quot;, &quot;A_0403788-001-AA&quot;, &quot;A_0403789-001-AA&quot;),
                    mass = c(&quot;697.3475489&quot;, &quot;697.3475489&quot;, &quot;782.3461691&quot;, &quot;634.259184&quot;, &quot;618.3417352&quot;, &quot;618.3417352&quot;, &quot;636.2981563&quot;, &quot;636.2981563&quot;, &quot;782.3461691&quot;, &quot;618.3417352&quot;, &quot;634.259184&quot;, &quot;634.259184&quot;, &quot;729.31962&quot;, &quot;728.3243711&quot;, &quot;728.3243711&quot;, &quot;729.31962&quot;, &quot;771.4119607&quot;, &quot;771.4119607&quot;, &quot;783.3665702&quot;, &quot;783.3665702&quot;, &quot;784.3708241&quot;, &quot;784.3708241&quot;))
  </code></pre>
  <p><a href="https://i.stack.imgur.com/0OC8U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0OC8U.png" alt="enter image description here" /></a></p>