[R] Union of list elements
ggrothendieck at myway.com
Fri Dec 17 21:04:08 CET 2004
Patrick Meyer <patrick.meyer <at> internet.lu> writes:
: Thank you Gabor.
: But I have a problem with the beginning of my algorithm, where the list
: you call L is empty... then the code breaks down... It says:
: "Error in any(...,na.rm = na.rm) : incorrect argument type"
: How can I handle this?
Good point. We can rescue it by doing the simplification ourself
using unlist(lapply(...)) instead of sapply(...):
L <- list()
newentry <- c("a3", "a1", "a4")
if (!any(unlist(lapply(L, setequal, newentry)))) L <- c(L, list(newentry))
More information about the R-help