-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
## convert names columns with one hot encoding to list of column names
tags2list <- function(data, ...){
data %>%
select(...) %>%
{Map(function(x, y){
ifelse(x > 0, y, NA)
}, ., names(.))} %>%
unlist(use.names = FALSE)
}
list2tags <- function(data, ncol = length(unique(na.omit(unlist(data))))){
# browser()
lapply(data, function(x){
x %>%
matrix(ncol = ncol) %>%
as.data.frame()
}) %>%
bind_rows() %>%
{Map(function(x){
setNames(tibble(x = ifelse(is.na(x), 0L, 1L)), unique(na.omit(x)) )
}, .)} %>%
bind_cols()
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels