I want to create a segment/point plot that has the topBatter on the Y axis and the topTen Distance on the Y axis. When I create it the plot reverses the X and Y.
I'm a bit stuck as to why this one isn't working.
Thanks for any guidance. I appreciate this community.
#Top HR by Distance topTenDistance <- c(485, 502, 484, 492, 489, 499, 500, 497, 489, 501) topBatter <- c("Ba", "Ca", "Da", "Fa", "Ga", "Ha", "Ja", "Ka", "Ya", "Ja") topCombined <- cbind(topBatter, topTenDistance) topCombined <- as.data.frame(topCombined) topCombined %>% ggplot(aes(x=topTenDistance, y=topBatter)) + geom_segment( aes(xend=topTenDistance, yend=0)) + geom_point( size=1.5, color="#134A8E") + scale_y_discrete() + coord_flip() + ggtitle("Top HRs by Distance") + labs(subtitle = "MLB 2022 Season") + xlab("Player's Name") + ylab("Distance (in ft") 

batter_last_nameis a factor, not a continuous variable. Hence the error. Also, I strongly usrge you not to uselimitsto define the limits of your axes. This filters the data and then constructs summaries, which can lead to unexpected and erroneous results.coord_cartesianis far better, IMHO, because it uses the whole dataset to construct the graph and then "zooms" to the required region.coord_flip()flips the axes. If you don't want the axes flipped, don't usecoord_flip.