I have a list
of character
vector
s:
my.list <- list(e1 = c("a","b","c","k"),e2 = c("b","d","e"),e3 = c("t","d","g","a","f"))
And I'm looking for a function
that for any character
that appears more than once across the list
's vector
s (in each vector
a character
can only appear once), will only keep the first appearance.
The result list for this example would therefore be:
res.list <- list(e1 = c("a","b","c","k"),e2 = c("d","e"),e3 = c("t","g","f"))
Note that it is possible that an entire vector
in the list
is eliminated so that the number of elements in the resulting list
doesn't necessarily have to be equal to the input list
.
x=list(a=1,b='2'); relist(unlist(x),skel=x)
yieldslist(a='1',b='2')
– Leucoderma