Using the identify function in R

label, r, scatter-plot

Solution

# Here is an example

x = 1:10
y = x^2

name = letters[1:10]    
plot(x, y)

identify(x, y, labels = name, plot=TRUE)

# Now you have to click on the points and select finish at the end
# The output will be the labels you have corresponding to the dots.

Regarding saving it: I couldn't do it using

pdf() 
# plotting code
dev.off()

However in Rstudio it was posible to "copy-paste" it. If you need one plot only, i guess this would work.

Problem

In a scatterplot, I would like to use `identify` function to label the right top point. I did this: ``` identify(x, y, labels=name, plot=TRUE) ``` *I have a named vector. Then, while it is running, I point to the right point. Then after stopping it, it shows me the label of the point. Do I have to click the point that I want to label each time? Can I save it?

Original source