Adding text labels to a plot

What does geom_text() do?

It adds names (labels) to the points on the plot.

Where does R get the labels?

The easiest solution is to store the labels as one of the columns of the data frame you use as input for the ggplot() function. Assume the column is called L. Then you can just use the column name inside aes():

ggplot(D,aes(X,Y)) + geom_label_repel(aes(label=L))

Row names cannot be used because ggplot2 doesn’t see them as a column in the data frame: you cannot use rownames(D) inside aes()