Add `combine_lexicon`
trinker opened this issue · comments
A function to take lexicons (named) combine them together removing dupes (for lookups dupes replaced by first value)
combine_lexicon <- function(lexicons, ask.dupes = FALSE, ...){
## check that all lexicons are of the same type (grouped together)
## manual mapping? or by naming convention?
## get internal data
dats <- lapply(lexicons, function(x) eval(parse(text = paste0('lexicon::', x))))
## handling for atomic vs tabular
if (is.atomic(dats)) {
} else {
## for tabular lexicons
if (ask.dupes){
## interactively as for which dupe to keep
} else {
## keep first dupe
}
## handling for unequal nuber of columns
## handling for data.table keyed lookups
}
}
For tables use: data.table::rbind.list (fill=TRUE)
Also remove duplicate rows.
This really isn't any better than using c
or rbind.list