I'm trying to pass a vector in the tidyr 'crossing' function, but I don't see how to do it. Here's what I want to do: I want to crossproduct the objects michel, anita, robert to obtain the dataframe everybody as follow:
# objects to combine
michel <- c("Berlin","Tokyo","Amsterdam")
anita <- c("London","Montreal")
robert <- "Moscow"
# combination
library(tidyr)
everybody <- crossing(michel,anita,robert)
Thing is, I want to pick the list michel, anita, robert from a dataframe (or vector), then pass that vector to the crossing function (so that everybody2 is the same as everybody):
# vector with names:
vector1 <- as.data.frame(c("michel","anita","robert"))
# how to pass 'vector1' into crossing?
everybody2 <- crossing(vector1)
I don't see how I can make it work... any advice?
Thank you in advance!