I have a dataframe and I want to create another data frame with all possible combinations of distinct values of each variable of the first data frame
dt = data.frame(A = c(10,2,3,8,2), B = c("K","F","F","K","K"))
dt1 <- dt %>% distinct(A)
dt2 <- dt %>% distinct(B)
expand.grid(A = dt1, B = dt2)
However this code returns the following error:
Warning message:
In format.data.frame(if (omit) x[seq_len(n0), , drop = FALSE] else x, :
corrupt data frame: columns will be truncated or padded with NAs