[R] adding results to plot

PIKAL Petr petr@p|k@| @end|ng |rom prechez@@cz
Fri Sep 17 08:15:10 CEST 2021


Thanks Jim

This seems to be strightforward and quite simple. I considered addtable2plot 
but was not sure how to make propper data frame from the result.

Regards
Petr

> -----Original Message-----
> From: Jim Lemon <drjimlemon using gmail.com>
> Sent: Friday, September 17, 2021 2:31 AM
> To: PIKAL Petr <petr.pikal using precheza.cz>; r-help mailing list <r-help using r-
> project.org>
> Subject: Re: [R] adding results to plot
>
> Hi Petr,
> The hard part is the names for the data frame that addtable2plot requires:
>
> set.seed(753)
> res <- shapiro.test(rnorm(100))
> library(plotrix)
> plot(0,0,type="n",axes=FALSE)
> addtable2plot(0,0,data.frame(element=names(res)[1:2],
>   value=round(as.numeric(res[1:2]),3)),xjust=0.5,
>   title=res$method)
>
> There is probably a way to get blank names with data.frame(), but I gave up.
>
> Jim
>
> On Fri, Sep 17, 2021 at 12:22 AM PIKAL Petr <petr.pikal using precheza.cz> wrote:
> >
> > Dear all
> >
> > I know I have seen the answer somewhere but I am not able to find it.
> > Please help
> >
> > > plot(1,1)
> > > res <- shapiro.test(rnorm(100))
> > > res
> >
> >         Shapiro-Wilk normality test
> >
> > data:  rnorm(100)
> > W = 0.98861, p-value = 0.5544
> >
> > I would like to add whole res object to the plot.
> >
> > I can do it one by one
> > > text(locator(1), res$method)
> > > text(locator(1), as.character(res$p.value))
> > ...
> > But it is quite inconvenient
> >
> > I could find some way in ggplot world but not in plain plot world.
> >
> > Best regards
> > Petr
> > ______________________________________________
> > 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