Reputation:
I am trying to rename a column name after conducting summarise(sum)
The code as it is now is the follow
Tix <- GoT %>%
filter(Total_Tickets_Purchased >= 1) %>%
group_by(DayDif) %>%
summarise(sum(Total_Tickets_Purchased))
This calculates everything correctly but the column name is sum(Total_Tickets_Purchased). When conducting further code, it is not recognizing it as the column name
I have tried to following code to do so.
Tix <- GoT %>%
filter(Total_Tickets_Purchased >= 1) %>%
group_by(DayDif) %>%
summarise(sum(Total_Tickets_Purchased)) %>%
rename(c[,2] = Total)
This results in the following error
error: unexpected '=' in:
" summarise(sum(Total_Tickets_Purchased)) %>%
rename(c[,2] ="
Does anyone have advice?
Upvotes: 0
Views: 927
Reputation: 769
Try
Tix <- GoT %>%
filter(Total_Tickets_Purchased >= 1) %>%
group_by(DayDif) %>%
summarise(Total = sum(Total_Tickets_Purchased))
Upvotes: 2