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,

xbarvazx
  • 57
  • 3
  • Possible duplicate of [Concatenate strings and expressions in a plot's title](https://stackoverflow.com/questions/4302367/concatenate-strings-and-expressions-in-a-plots-title) – qdread Jan 17 '18 at 12:37

1 Answers1

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)))
P. Denelle
  • 790
  • 10
  • 24