I'm trying to summarise a table in R and unsure the best way to approach it.
I've attempted this with the dplyr summarise but it does not seem to be very efficient, nor obvious what I need to do.
Starting Data
table <- data.frame(Company1 = c("A","A","C","C"), Company2 = c("B", "B",
"D", "D"), target = c("sales", "turnover", "sales", "turnover"), result =
c(200, 5000, 300, 7500))
Company1 Company2 target result
1 A B sales 200
2 A B turnover 5000
3 C D sales 300
4 C D turnover 7500
Expected
Company1 Company2 Sales Turnover
1 A B sales - 700 turnover - 5000
2 C D sales - 300 turnover - 7500