library(knitr)
data <- data.frame(
  Group = c("A", "B", "C"),
  Mean  = c(5.2, 6.8, 4.9),
  SD    = c(1.1, 0.9, 1.3)
)
data  Group Mean  SD
1     A  5.2 1.1
2     B  6.8 0.9
3     C  4.9 1.3Tables are a common way to summarize data in reports. Quarto allows you to produce tables directly in Markdown or dynamically from R. Using clear, readable tables improves the presentation of results and makes your documents more professional and accessible.
For simple tables, you can write them directly in Markdown using the pipe (|) syntax. This is ideal for small, static tables that do not require dynamic calculations.
Example:
Rendered output:
| Group | Mean | SD | 
|---|---|---|
| A | 5.2 | 1.1 | 
| B | 6.8 | 0.9 | 
| C | 4.9 | 1.3 | 
--- under headers for proper alignment.: on left), right (: on right), or center (: on both sides):Results in aligned columns like this:
| Group | Mean | SD | 
|---|---|---|
| A | 5.2 | 1.1 | 
| B | 6.8 | 0.9 | 
| C | 4.9 | 1.3 | 
knitr::kableFor tables that come from your R data (e.g., data frames, summaries), Quarto integrates seamlessly with knitr::kable to produce clean, nicely formatted tables.
Example:
When producing tables are raw output, they will look like this:
library(knitr)
data <- data.frame(
  Group = c("A", "B", "C"),
  Mean  = c(5.2, 6.8, 4.9),
  SD    = c(1.1, 0.9, 1.3)
)
data  Group Mean  SD
1     A  5.2 1.1
2     B  6.8 0.9
3     C  4.9 1.3When using kable, they can be formatted more neatly:
| Group | Mean | SD | 
|---|---|---|
| A | 5.2 | 1.1 | 
| B | 6.8 | 0.9 | 
| C | 4.9 | 1.3 | 
caption adds a descriptive label for the table.kable automatically aligns columns neatly.kableExtra to add styling, colors, or column formatting.library(kableExtra)
mean_score <- mean(data$Mean)
kable(data, caption = paste("Summary statistics (overall mean:", round(mean_score, 2), ")")) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE) %>%
  row_spec(0, bold = TRUE, color = "white", background = "#4CAF50")  # header row styling| Group | Mean | SD | 
|---|---|---|
| A | 5.2 | 1.1 | 
| B | 6.8 | 0.9 | 
| C | 4.9 | 1.3 | 
kable_styling(): Adds table styling options like striped rows, hover effect, and condensed spacing.row_spec(0, ...): Styles the header row (0 = header) with bold text, white font, and a green background.Rendered in HTML, this produces a professional, readable table that’s visually distinct and easier to interpret than a plain kable() table.
You can also add row colors, column formatting, or footnotes with other kableExtra functions for even more control.
kable) for consistency.For more detail, see the Quarto documentation