I have a document for which I’d like to produce graphs and tables side-by-side. I’ve done hours of searching on the internet, and after lots of trial and error, found that adding the line “#| layout-ncol: 2” is the only thing that seems to actually get these things side-by-side. However, this format makes the graphs look pretty small. Is there any way to make the column with the graph in it wider so that it is more readable?
The table also ends up taking up all of the right column, but I think it would take up less space if the font were smaller. So how do I make the font in the table smaller so the graph has room to be bigger?
Below is a reproducible example using the Iris data. This is obviously not the actual data I am working with, so I made the title of the left column longer to simulate the width of the table for my real data.
---
title: "`r paste('Information on petal width for', params$species)`"
date: "Report Generated on `r format(Sys.Date(), '%B %d, %Y')`"
format: pdf
mainfont: ArialMT
editor: visual
params:
species: setosa
---
knitr::opts_chunk$set(echo = FALSE, comment = NA, tidy.opts=list(width.cutoff=60),tidy=TRUE, warning = FALSE)
library(tidyverse)
library(tinytex)
library(kableExtra)
table <- iris %>%
group_by(Species) %>%
summarize (PetalWidth = mean(Petal.Width),
SepalLength = mean(Sepal.Length),
SepalWidth = mean(Sepal.Width))
iris$Petal.Width <- as.factor(iris$Petal.Width)
iris$Sepal.Length <- as.factor(iris$Sepal.Length)
iris$Sepal.Width <- as.factor(iris$Sepal.Width)
Petal Width
#| layout-ncol: 2
ggplot(iris, aes(x = Petal.Width, fill = Petal.Width)) +
geom_bar(position = 'dodge', stat = 'count')
kable(table[, c(1, 2)], row.names = FALSE, col.names = c("This is the species of the Iris", "Petal Width"), )
So far I’ve tried many ways of making the text in my table smaller, including using piping with kableExtra, which worked to shrink the text but made the table have thick borderlines, which made it unreadable. I experimented with different styles to fix this, but it didn’t work. I prefer the style produced with the code above, but smaller text.
To widen the graph, I honestly have no clue where to begin. I don’t even know what language uses the form #| for codes, and Google didn’t help me. I am pretty new to using markdown and this is my first foray into Quarto. I have never produced reports before, never worked with Latex or python, don’t know CSS or HTML and have no clue what I am doing. Help!