Q:

R Add string and variable to a plot with text(...)

corval<-cor(airquality$Solar.R,airquality$Temp,use="complete.obs")
coord<-locator(n=1)
text(coord,expression("Correlation=", corval))

I'm trying to add text that contains both a string and an integer to a plot but I can't find out how to get the numerical value of the variable to display, this is just one of the ways I've tried.

A:

I think that you mean to plot airquality$Solar.R against airquality$Temp and then add this label to the plot.   If you have clicked on a good place for the center of the text, you can use:
plot(airquality$Solar.R,airquality$Temp)
text(coord, paste0("Corval=", round(corval, 3)))

