I have a data set that look like the following: https://i.stack.imgur.com/0i8Cj.png
Name | State | Zipcode | County_name | average payment | Frequency
My desired output would be to group by State and have the Median payment using the average payment and Frequency columns.
I know how to do this for the overall dataset
median(rep(Clean$medicare_average_payment, Clean$Frequency))
but not sure how to do this by State Thank you