I have a data frame that is comprised of the stats of nba players. The id of each element is the player's name, and the other columns in the data frame contain stats (numeric class) and factor variables like the player's team. I am trying to plot the relationship between two statistics for each player, and then facet the plots by the player's position (factor variable). When I make the plot (code below) the player's team data is jumbled, and misapplied to the players.
The below code shows what position players should be assigned to
example <- arrange(combined, desc(cap.adjusted.worp))
head(example[, 1:3])
> head(example[, 1:3])
Tm Player Pos
1 GSW Stephen Curry PG
2 OKC Russell Westbrook PG
3 CLE LeBron James SF
4 HOU James Harden SG
5 TOR Kyle Lowry PG
6 OKC Kevin Durant SF
Code to make plot
gg <- ggplot(combined, aes(combined$Salary / 1000000, combined$cap.adjusted.worp))
gg <- gg + geom_point() + facet_wrap(~Pos, nrow = 1)
gg <- gg + geom_text(label = combined$Player, size = 2.5)
gg <- gg + xlab("Salary in Millions") + ylab("Cap Adjusted WORP")
gg <- gg + geom_vline(xintercept = combined$avg.salary / 1000000, combined)
gg <- gg + geom_hline(yintercept = combined$avg.worp, combined)
gg <- gg + geom_smooth(method = "lm", se = FALSE, size = 1)
gg <- gg + ggtitle("Relationship between Cap Adjusted Wins Over Replacement Player and Salary by Player")
gg
My plot with the misapplied or labeled position variables
*I don't have enough reputation points to post images so here is an imgur link to the plot made from the above code https://i.stack.imgur.com/BnumJ.jpg