The error is occurring before pivot_wider. I think the following line is causing the problem:
summarise(sum_layer1 = sum(LAYER_1)(Location_fac, RATING_fac))
I'm not sure what (Location_fac, RATING_fac) is intended to be doing, but it is not correct syntax.
Also, the group_by is not causing an error, but it is also not doing anything because no grouping columns have been entered.