0

How can I integrate this phrase into the text function: expression(R^2,"=", round(cor(tkw14_cor$TKW, tkw14_cor$Yield),2)) I also tried expression(R^2 == round(cor(tkw14_cor$TKW, tkw14_cor$Yield),2))) and expression(R^2 ~ == ~ round(cor(tkw14_cor$TKW, tkw14_cor$Yield),2))) and all the 'paste' possibilities.. It does not work like this. My goal is to have the text print: R^2 (as superscript) = rounded correlation coefficient.

Thanks,

1

1 Answer 1

0

You can use bquote function.

Random example here:

plot(1)
set.seed(1)
value <-  round(cor(rnorm(1000), rnorm(1000)), 2)
text(1,1.2,bquote("R"^"2" ~ " = " ~.(value)))
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.