My two lists look like below
Need an R code example that
combines the two.
l_one
key
2
1
2
l_two
ndx, descr
1, this
2, that
3, other
4, finis
My goal is a new list that looks
like below.
ndx descr
2 that
1 this
2 that
Thanks,
Jim
__
Hi Jim,
Here is one way:
# How I imagine your data might be stored
l_one - list(structure(list(key = c(2, 1, 2)), .Names = key,
row.names = c(NA,
-3L), class = data.frame))
l_two - list(structure(list(ndx = 1:4, descr = c(this, that, other,
finis)), .Names = c(ndx, descr), row.names = c(NA,
Hi:
Is this what you need?
l_one - data.frame(key = c(2, 1, 2))
l_two - data.frame(ndx = 1:4, descr = c('this', 'that', 'other', 'finis'))
merge(l_one, l_two, by.x = 'key', by.y = 'ndx')
key descr
1 1 this
2 2 that
3 2 that
HTH,
Dennis
On Wed, Oct 27, 2010 at 10:53 AM, Jim Burke
3 matches
Mail list logo