I currently have a table for NFL player stats. Column A is Player Position, Column B is Player Name, Column C is player projected rank for that week, Column D is how many fantasy points they got that week. Something like this..
pos <- c("QB", "QB", "QB", "RB", "RB")
name <- c("Tom Brady", "Matt Ryan", "Aaron Rodgers", "Leveon Bell", "Devonta Freeman")
proj <- c(20.5, 18.5, 21.3, 22.5, 16.5)
actual <-c (15, 21.4, 19.0, 15.1, 12.4)
rawdata <- data.frame(pos, name, proj, actual)
Since there are 8 weeks so far, each player has 8 rows of data (1 per week). How can I consolidate this so that I can get the average projection and actual data for any given individual? Ex: I want to get the mean projection (Column C) and mean actual data (Column D) for Matt Ryan (Column B)
Bonus: What if I wanted to get the mean projection (Column C) and mean actual data (Column D) for any given position? (Column A)
Thanks!