Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your data</p> <pre><code>df &lt;- list(structure(list(a = 1:5, b = 6:11), .Names = c("a", "b")), structure(list(a = 6:11, b = 1:5), .Names = c("a", "b")), structure(list(a = 12, b = 12), .Names = c("a", "b"))) </code></pre> <p>This gives you the unique values of the nested lists:</p> <pre><code>library(plyr) df.l &lt;- llply(df, function(x) unlist(unique(x))) R&gt; df.l [[1]] [1] 1 2 3 4 5 6 7 8 9 10 11 [[2]] [1] 6 7 8 9 10 11 1 2 3 4 5 [[3]] [1] 12 </code></pre> <p><strong>EDIT</strong></p> <p>Thanks to Ramnath I changed the code a bit and hope this answer fits the needs of your question. For illustration I keep the previous answer as well. The slightly changed data has now an additional list.</p> <pre><code>df &lt;- list(structure(list(a = 1:5, b = 6:11), .Names = c("a", "b")), structure(list(a = 6:11, b = 1:5), .Names = c("a", "b")), structure(list(a = 12, b = 12, c = 10:14), .Names = c("a", "b", "c"))) f.x &lt;- function(x.list) { x.names &lt;- names(x.list) i &lt;- combn(x.names, 2) l &lt;- apply(i, 2, function(y) x.list[y]) llply(l, unlist) } </code></pre> <p>Now you can apply the function to your data.</p> <pre><code>all.l &lt;- llply(df, f.x) llply(all.l, function(x) llply(x, unique)) R&gt; [[1]] [[1]][[1]] [1] 1 2 3 4 5 6 7 8 9 10 11 [[2]] [[2]][[1]] [1] 6 7 8 9 10 11 1 2 3 4 5 [[3]] [[3]][[1]] [1] 12 [[3]][[2]] [1] 12 10 11 13 14 [[3]][[3]] [1] 12 10 11 13 14 </code></pre> <p>However, the nested structure is not very user friendly. That could be changed a bit...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload