0

I want to add to ggplot (PLOT) graph a table reporting the significance of the analysis of variance:

aov2<-aov(Ce~O+H+O:H, data=df)
mytable<-summary(aov2)

I have tried:

PLOT+
mtext(mytable)
Error in mtext(mytable) : plot.new has not been called yet
Al14
  • 1,734
  • 6
  • 32
  • 55
  • mtext does not work with `ggplot2` plots, only with base. See [this previous question](https://stackoverflow.com/questions/13009135/how-to-annotate-ggplot2-qplot-outside-of-legend-and-plotarea-similar-to-mtext) for the ggplot equivalent – jeremycg Sep 14 '15 at 17:46
  • Also [this question](http://stackoverflow.com/questions/12409960/ggplot2-annotate-outside-of-plot) – user295691 Sep 14 '15 at 17:52
  • 1
    [This one](http://stackoverflow.com/questions/12318120/adding-table-within-the-plotting-region-of-a-ggplot-in-r) seems the most on point – user295691 Sep 14 '15 at 17:53
  • @user295691 this is actually very close to my point, but it requires to build the table manually in advance – Al14 Sep 14 '15 at 17:59

1 Answers1

0

The questions linked show how to add a table to a plot, but in order to produce that, you need a table to start with.

To get a table from the summary object, you need to extract the actual table from the summary.

mytable <- summary(aov2)[[1]]

will do the trick.

user295691
  • 7,108
  • 1
  • 26
  • 35