1
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.

0

1 Answer 1

1

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)))

Corval

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.