[R] Help

Kimmo Elo k|mmo@e|o @end|ng |rom utu@||
Mon Feb 5 07:40:17 CET 2024


Hi,

the command line with 'text' should be:

text(-8,-8, expression(R^2 * " = 0.62,  r = 0.79, N = 161"), cex = 2 )

Best,

Kimmo

su, 2024-02-04 kello 17:16 +0100, Jibrin Alhassan kirjoitti:
> Here is the script I used to plot the graph indicating the text I
> wanted to
> insert. The line in the script that I have issues with is: text(-8,-
> 8,
> "R^2=  0.62",  r = 0.79, N = 161", cex = 2
> R^2=  0.62 is not producing R squared = 0.62.
> Thanks.
> Sys.setenv( TZ="GMT" )
> dt <- read.table("CLMXAPTY_sim", col.names = c("FDcli", "FDapt"))
> FDcli=dt$FDcli
> FDapt=dt$FDapt
> setEPS()
> postscript(file = "cliapt2.eps")
> par(mar = c(4.3, 4.3, 1.3, 1.3), oma = c(1, 1, 1 , 1))
> plot(FDapt,FDcli, pch = 16,  cex.lab = 1.6, cex.axis = 1.4, cex.main
> = 0.8,
> font.lab = 1.7, font.axis = 1.7,  col = "red",main = "Simultaneous
> Events
> at CLMX and APTY",ylab="CLMX",xlab="APTY")
> text(-8,-8, "R^2=  0.62",  r = 0.79, N = 161", cex = 2 )
> abline(lm(FDcli ~ FDapt, col="black"))
> dev.off()
> *Jibrin Adejoh Alhassan (Ph.D)*
> Department of Physics and Astronomy,
> University of Nigeria, Nsukka
> 
> 
> On Sun, Feb 4, 2024 at 5:03 PM Jibrin Alhassan
> <jibrin.alhassan using unn.edu.ng>
> wrote:
> 
> > Hi Elo,
> > It gave this error message:
> > CR_plot2.R:14:37: unexpected string constant
> > 13: plot(FDapt,FDcli, pch = 16,  cex.lab = 1.6, cex.axis = 1.4,
> > cex.main =
> > 0.8, font.lab = 1.7, font.axis = 1.7,  col = "red",main =
> > "Simultaneous
> > Events at CLMX and APTY",ylab="CLMX",xlab="APTY")
> > 14: text(-8,-8, "expression(R^2*"=  0.62"),  r = 0.79, N = 161"
> >                                         ^
> > *Jibrin Adejoh Alhassan (Ph.D)*
> > Department of Physics and Astronomy,
> > University of Nigeria, Nsukka
> > 
> > 
> > On Sun, Feb 4, 2024 at 4:45 PM Jibrin Alhassan
> > <jibrin.alhassan using unn.edu.ng>
> > wrote:
> > 
> > > Thank you Zhao for the code. When I replotted the graph after
> > > inserting
> > > the code in my script, it gave me this error message without
> > > plotting the
> > > graph:
> > > Warning message:
> > > In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...)
> > > :
> > >  extra argument ‘col’ will be disregarded.
> > > My regards.
> > > *Jibrin Adejoh Alhassan (Ph.D)*
> > > Department of Physics and Astronomy,
> > > University of Nigeria, Nsukka
> > > 
> > > 
> > > On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao <jszhao using yeah.net>
> > > wrote:
> > > 
> > > > ?plotmath
> > > > 
> > > > expression(R^2==0.62)
> > > > 
> > > > On 2024/2/4 18:10, Jibrin Alhassan wrote:
> > > > > I have done a scatter plot in R. I want to insert the
> > > > > coefficient of
> > > > > determination R^2 = 0.62 as a text in the plot. I have tried
> > > > > to write
> > > > R^2
> > > > > but could not produce R2. I would appreciate it if someone
> > > > > could help
> > > > me
> > > > > with the syntax. I have tried:  expression(paste("", R^2,"=",
> > > > > 0.62)),
> > > > but
> > > > > it did not produce R squared, rather it gave me error
> > > > > messages. Thanks.
> > > > > Jibrin Alhassan
> > > > > *Jibrin Adejoh Alhassan (Ph.D)*
> > > > > Department of Physics and Astronomy,
> > > > > University of Nigeria, Nsukka
> > > > > 
> > > > >       [[alternative HTML version deleted]]
> > > > > 
> > > > > ______________________________________________
> > > > > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more,
> > > > > see
> > > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > > > PLEASE do read the posting guide
> > > > http://www.R-project.org/posting-guide.html
> > > > > and provide commented, minimal, self-contained, reproducible
> > > > > code.
> > > > 
> > > > ______________________________________________
> > > > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more,
> > > > see
> > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > > PLEASE do read the posting guide
> > > > http://www.R-project.org/posting-guide.html
> > > > and provide commented, minimal, self-contained, reproducible
> > > > code.
> > > > 
> > > 
> 
>         [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list