Skip to content

Add hierarchy function to apply this to any network #4

@TheZetner

Description

@TheZetner

`

listvars <- vars %>%
purrr::pmap(~ CCT::getDescendants(dat$hierarchy$network, .x, table = T)) %>%
purrr::set_names(vars$lineage)

uniqueListElements <- function(list){

Loop through each element of the list and compare to each other

for( i in 1:length(list)){ # Set to compare
for(j in 1:length(list)){ # Set to compare against
if(i!=j){ # Are the indices the same? Skip. Otherwise...
if(any(list[[i]]%in%names(list)[j])){ # Is j's name in set i?
list[[i]]=setdiff(list[[i]],list[[j]]) # Remove j elements from i
}
}
}#end j
}#end i
return(list)
}

allvars <-
listvars %>%
dplyr::bind_rows(.id = "parent") %>%
dplyr::select(parent, lineage)

unique.groups <-
uniqueListElements(split(allvars$lineage, allvars$parent))
unique.groups <-
stack(unique.groups) %>%
dplyr::select(lineage = ind, child = values)

dplyr::left_join(unique.groups, vars)

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions