I have a dataset that looks like
City Score Count Returns
Dallas 2.9 61 21
Phoenix 2.6 52 14
Milwaukee 1.7 38 7
Chicago 1.2 95 16
Phoenix 5.9 96 16
Dallas 1.9 45 12
Dallas 2.7 75 45
Chicago 2.2 75 10
Milwaukee 2.6 12 2
Milwaukee 4.5 32 0
Dallas 1.9 65 12
Chicago 4.9 95 13
Chicago 5 45 5
Phoenix 5.2 43 5
I would like to build a report using R markdown; however, for each city I need to build a report. The reason for this is that one city cannot see the report for another city. How do I build a report and save a PDF of it for each city?
Each report would need the median Score, mean Count, and mean Returns. I know that using dplyr I could simply use
finaldat <- dat %>%
group_by(City) %>%
summarise(Score = median(Score),
Count = mean(Count) ,
Return= mean(Returns))
But the frustration comes from producing a report for each City. Also, this is a subset of the data, not the full data. That is, this report is extensive and is a report of the results, which is systematic, not different for each City.