Hi, I have a grouped_by and summarized tibble. I can't think of a simple way to convert it to a base R table. The following is a simple example:
factor1 <- c(0,0,0,0,1,1,1,1)
factor2 <- c(0,0,1,1,0,0,1,1)
sales <- c(10,10,15,20,20,30,30,40)
df <- data.frame(factor1, factor2, sales)
suppressMessages(library(dplyr))
df1 <- df %>%
group_by(factor1, factor2) %>%
summarise(total = sum(sales))
df1
factor1 factor2 total
1 0 0 20
2 0 1 35
3 1 0 50
4 1 1 70
What I want is a base R table like this:
0 1
0 20 35
1 50 70