Search code examples
rr-markdownminimizegooglevis

googleVis minimizes text and tables in R markdown


I'm trying to make a report with R markdown, kable and googleVis. It almost works perfectly fine, the tables and graphs are produced. However, if I try to put graphs AND tables in the rmarkdown, the tables and any text that is not a header is minimized, making them hard to read.

If I only put tables in the markdown file, the tables are a nice size. I would like to know why the tables and text are minimized when graphs from googleVis are added and how I can prevent this.

The following is a reproducible code:

```{r results='asis'}
   values1 <- c(36, 9, 21, 16)
   values2 <- c(5, 5, 0 ,6)
   variables <- c("Total", "Var1", "Var2", "Var3")

   table <- data.frame(variables, values1, values2)
   kable(table, caption = "example table")
```

```{r results='asis'}
  values3 <- c(1, 3, 0, 9)
 values4 <- c(4, 6, 3 ,2)
 pievariables <- c("ISV", "TAO", "PRR", "AV")

 piechart <- data.frame(pievariables, values3, values4)

 Pie <- gvisPieChart(piechart[,1:2], options=list(title='example pie',
                                                      width = 400, 
                                                      height = 400,
                                                      pieSliceText='label'))
 Pie
```

Solution

  • replace Pie with print(Pie, "chart"):

    Pie <- gvisPieChart(piechart[,1:2], options=list(title='example pie',
                                                     width = 400, 
                                                     height = 400,
                                                     pieSliceText='label'))
    
    print(Pie, "chart)
    

    this should do the work