Rendering SQL output in R Markdown

Hello,

I'm including some SQL in an RMarkdown document. Though it renders fine inside the RStudio IDE, when I render the page to HTML the output is printed as unformatted text all pushed together. How do I print it in a proper table form?

I did not include a proper reprex because it won't render the RMarkdown here in the community. Each RMarkdown chunk is ended with ```, but it's not rendering correctly here.

```{r sql_data, include=FALSE}
library(tidyverse)
library(gapminder)
library(dbplyr)
library(DBI)
mydb <- DBI::dbConnect(RSQLite::SQLite(), "")
dbWriteTable(mydb, "gapminder", gapminder)
src_dbi(mydb)

```{sql, connection=mydb}
SELECT * FROM gapminder

Which then outputs the following when the HTML is rendered:

gap

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.