Hi,
I have a list named lst which has an arbitrary number of named elements. For
example:
print(lst)
$a:
[1] 10
$b:
[1] 20
I would like to extract the elements that match a vector of names but I want
the result contains only the matched elements. For example, if I do the
following command:
lst.match _ lst[c("a","c")]
I would like the result:
$a:
[1] 10
and not:
$a:
[1] 10
$"":
NULL
Is there a simple way to do that (maybe something that uses drop) other than
doing a second command like:
lst.match[unlist(lapply(lst.match,function(x) !is.null(x)))]
Thank you for any hint,
Patrick
_________________________________________________________________
Take advantage of powerful junk e-mail filters built on patented Microsoft®
SmartScreen Technology.
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
Start enjoying all the benefits of MSN® Premium right now and get the
first two months FREE*.
|