I am working with the R programming language.
Suppose I have the following data frame that contains different food and drink choices:
library(dplyr) data_frame = data.frame(food = c("pizza", "tacos", "nachos"), drinks = c("water", "coffee", "pop"))
I then made a "list" that contains every possible selection of these food and drink items:
lst1 <- lapply(data_frame, function(x) c("none", unlist(lapply(seq_len(length(x)), function(i) combn(x, i, FUN = paste, collapse = " & ")))))
My Question: I would like to take this above list and make a "tree" that shows every possible combination of food and drink choices that can be ordered together - this should look something like this:
Is it possible to do this in R using libraries such as "data.tree" and "ggplot2"?
I found this previous stackoverflow post (igraph graph.lattice for all combinations (in R) - Stack Overflow) - but I am not sure how to adapt the code provided there for my problem.
Can someone please show me how to do this?