res is a list of class "htest" . You can only add text strings to a
plot via text(). I don't know what ggplot does.
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Sep 16, 2021 at 7:22 AM PIKAL Petr <petr.pikal at 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
Hi!
Maybe with this:
text(x=0.6, y=1.2, paste0(capture.output(res), collapse="\n"), adj=0)
HTH,
Kimmo
to, 2021-09-16 kello 14:12 +0000, PIKAL Petr kirjoitti:
Virhe vahvistaessa allekirjoitusta: Virhe tulkittaessa
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
...
But it is quite inconvenient
I could find some way in ggplot world but not in plain plot world.
Best regards
Petr
------=_NextPart_000_00C9_01D7AB15.A6E04EE0--
I was wrong. text() will attempt to coerce to character. This may be
informative:
as.character(res)
[1] "c(W = 0.992709285275917)" "0.869917232073854"
[3] "Shapiro-Wilk normality test" "rnorm(100)"
plot(0:1, 0:1); text(0,seq(.1,.9,.2), labels = res, pos = 4)
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Sep 16, 2021 at 7:44 AM Bert Gunter <bgunter.4567 at gmail.com> wrote:
res is a list of class "htest" . You can only add text strings to a
plot via text(). I don't know what ggplot does.
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Sep 16, 2021 at 7:22 AM PIKAL Petr <petr.pikal at 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
Thanks,
I will try to elaborate on it.
Best regards.
Petr
-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of Kimmo Elo
Sent: Thursday, September 16, 2021 4:45 PM
To: r-help at r-project.org
Subject: Re: [R] adding results to plot
Hi!
Maybe with this:
text(x=0.6, y=1.2, paste0(capture.output(res), collapse="\n"), adj=0)
HTH,
Kimmo
to, 2021-09-16 kello 14:12 +0000, PIKAL Petr kirjoitti:
Virhe vahvistaessa allekirjoitusta: Virhe tulkittaessa 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
...
But it is quite inconvenient
I could find some way in ggplot world but not in plain plot world.
Best regards
Petr
------=_NextPart_000_00C9_01D7AB15.A6E04EE0--
Hallo
Thanks, I will try wat option is better if yours or Kimmo's
Best regards
Petr
-----Original Message-----
From: Bert Gunter <bgunter.4567 at gmail.com>
Sent: Thursday, September 16, 2021 5:00 PM
To: PIKAL Petr <petr.pikal at precheza.cz>
Cc: r-help <r-help at r-project.org>
Subject: Re: [R] adding results to plot
I was wrong. text() will attempt to coerce to character. This may be
informative:
as.character(res)
[1] "c(W = 0.992709285275917)" "0.869917232073854"
[3] "Shapiro-Wilk normality test" "rnorm(100)"
plot(0:1, 0:1); text(0,seq(.1,.9,.2), labels = res, pos = 4)
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Sep 16, 2021 at 7:44 AM Bert Gunter <bgunter.4567 at gmail.com>
wrote:
res is a list of class "htest" . You can only add text strings to a
plot via text(). I don't know what ggplot does.
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Sep 16, 2021 at 7:22 AM PIKAL Petr <petr.pikal at 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
This is pretty kludgy but ...
res.p <-capture.output(x.t)
res.pl <- ''
res.nul <- sapply(res.p,function(x.c) res.pl <<-
paste(res.pl,res.c,sep='\n'))
text(x,y,rel.pl,pos=4,cex=mycex)
This will replicate the print object for the t.test that goes to the
screen so you can add it to a plot. One note, the output of several
lines will be left justified at the x-location but centered vertically
on the y-location. Experimental with the cex setting to fit it on your
plot. It will also put two blank lines above and one below so you might
strip those out for better positioning
David Stevens
On 9/16/2021 8:44 AM, Bert Gunter wrote:
res is a list of class "htest" . You can only add text strings to a
plot via text(). I don't know what ggplot does.
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Sep 16, 2021 at 7:22 AM PIKAL Petr <petr.pikal at 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
______________________________________________
R-help at 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.
CAUTION: This email originated from outside of USU. If this appears to be a USU employee, beware of impersonators. Do not click links, reply, download images, or open attachments unless you verify the sender?s identity and know the content is safe.
David K Stevens, PhD,PE
Professor
Civil and Environmental Engineering
Utah State University
Logan, UT 84322-8200
david.stevens at usu.edu
014357973229
This is pretty kludgy but ...
res.p <- capture.output(res) ? # creates a list of what goes to the screen
res.pl <- '' "?? # initialize res.pl
res.nul <- sapply(res.p,function(x.c) res.pl <<-
paste(res.pl,res.c,sep='\n'))? # adds the list items separated by a line
feed
text(x, y, res.pl, pos=4, cex=mycex)
This will replicate the print object for the t.test that goes to the
screen so you can add it to a plot. One note, the output of several
lines will be left justified at the x-location but centered vertically
on the y-location. Experimental with the cex setting to fit it on your
plot. It will also put two blank lines above and one below so you might
strip those out for better positioning
Best regards
David Stevens
On 9/16/2021 8:59 AM, Bert Gunter wrote:
I was wrong. text() will attempt to coerce to character. This may be
informative:
as.character(res)
[1] "c(W = 0.992709285275917)" "0.869917232073854"
[3] "Shapiro-Wilk normality test" "rnorm(100)"
plot(0:1, 0:1); text(0,seq(.1,.9,.2), labels = res, pos = 4)
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Sep 16, 2021 at 7:44 AM Bert Gunter <bgunter.4567 at gmail.com> wrote:
res is a list of class "htest" . You can only add text strings to a
plot via text(). I don't know what ggplot does.
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Sep 16, 2021 at 7:22 AM PIKAL Petr <petr.pikal at 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
______________________________________________
R-help at 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.
CAUTION: This email originated from outside of USU. If this appears to be a USU employee, beware of impersonators. Do not click links, reply, download images, or open attachments unless you verify the sender?s identity and know the content is safe.
David K Stevens, PhD,PE
Professor
Civil and Environmental Engineering
Utah State University
Logan, UT 84322-8200
david.stevens at usu.edu
014357973229
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 at 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
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 at gmail.com>
Sent: Friday, September 17, 2021 2:31 AM
To: PIKAL Petr <petr.pikal at precheza.cz>; r-help mailing list <r-help at 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 at 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