title: r: Inserting ggtexttable() inside a ggplot graph
body: <p>I'm trying to insert a table that I created using the ggtexttable() function from the ggpubr package inside the plotting boundary of my ggplot plot. However, I keep getting this error: </p>
  
  <pre><code>Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : 
    cannot coerce class "c("gg", "ggplot")" to a data.frame
  </code></pre>
  
  <p>I don't understand why I am getting error but I have a feeling it has to do with that I have dates on my x-axis? I would appreciate any feedback to fix this issue! Thanks! </p>
  
  <p><strong>Data:</strong></p>
  
  <pre><code>HUC_df1 &lt;- structure(list(charnam = c("Total dissolved solids", "Total dissolved solids", 
  "Total dissolved solids"), stdate = structure(c(11297, 11296, 
  11298), class = "Date"), val = c(439, 437, 510), HUC14 = c("HUC02030104020030", 
  "HUC02030104020030", "HUC02030104020030")), .Names = c("charnam", 
  "stdate", "val", "HUC14"), row.names = c(NA, -3L), class = c("tbl_df", 
  "tbl", "data.frame"))
  HUC1_count&lt;-structure(list(year = "2000", n_greater = 1L, percentage = 33.33, 
      n = 3L), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, 
  -1L), .Names = c("year", "n_greater", "percentage", "n"))
  </code></pre>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>library(ggpubr)
  library(ggplot2)
  
  theme_graphs&lt;- theme_linedraw()+
    theme(plot.title=element_text(size=15, face="bold",vjust=0.5,hjust = 0.5),
          panel.grid.major.x = element_blank(),
          panel.grid.minor.x = element_blank(),
          plot.background = element_blank(),
          panel.background = element_blank(),
          legend.position = c(0.5, 0.2),
          legend.background = element_blank(),
          legend.text=element_text(size=10, face="bold"))
  HUC1_table&lt;-ggtexttable(HUC1_count, 
                       theme = ttheme("classic"),rows=NULL,
                       cols=c("Year","Number of Samples\n&gt;500",
                              "Percent of Samples\n&gt;500","Total Samples"))
  HUC1&lt;-ggplot(data = HUC_df1, aes(x =stdate, y = val)) +
    geom_point()+
    geom_hline(aes(yintercept = 500,color="red"),size=1.3)+
    scale_y_continuous(expand = c(0, 0), limits = c(0))+
    coord_cartesian(ylim = c(0, 700))+
    scale_x_date(date_labels ="%b%Y")+
    ggtitle("Elizabeth R (below Elizabeth CORP BDY) (HUC02030104020030)\nTDS Concentration (mg/L);1997-2018") +
    xlab("Year") + ylab(" TDS Concentration (mg/L)")+
    scale_color_manual("",
                       values = c("red"),
                       labels=c("Freshwater Aquatic Life Criteria for TDS = 500 mg/L"))+
  
    theme_graphs+
    theme(legend.position =c(0.5, -0.098))
  
  
    HUC1&lt;-HUC1+annotation_custom(tableGrob(HUC1_table), xmin=1.5, 
                                 xmax=1.8,
                                 ymin=200, ymax=300)
  </code></pre>