Add the total to a table in R

60 views Asked by At

I want to create a table:

summary_table2 <- master_contracts %>%
  group_by(Branche) %>%
  summarise(Premium = round(sum(`Jahresbeitrag ohne Provision`))) %>%
  arrange(desc(Premium))

I would like to add the total:

total_sum2 <- master_contracts %>%
  summarise(Branche = "Total", Premium = round(sum(`Jahresbeitrag ohne Provision`)))

However, when I try to add the total to the table like this:

summary_table2 <- bind_rows(summary_table2, total_sum2)

I get an error message that the Premium from the summary_table2 is "character" and the premium from the total_sum2 is double so that I cannot combine the two as above.

Where have I gone wrong?

0

There are 0 answers