I have a dataset like this, extracted from a large and complex data frame:
data_set <- data.frame("Name" = c("Mr X", "Mr Y", "Mr Z", "Mr X", "Mr Z"), "Score" = c(88, 93, 87, 89, 90))
I want to create a list plot, ordered by Score, but with each Name appearing multiple times when needed. The following code does not produce the desired output because I want the two Scores of "Mr X" and the two scores of "Mr Z" to appear on different rows, instead of being grouped by default. What is cleanest way to do this?
data_set$Name <- reorder(data_set$Name, data_set$Score, min)
ggplot(data_set) + geom_point(aes(x = Score, y = Name))
I found this solution by adding a new factor without duplicates, and by mapping the labels to the old variable:
It is rather ugly, but I could not think of a cleaner solution.