Skip to content
Discussion options

You must be logged in to vote

I found a DT::datatable() solution based on this issue comment.

It is not perfect. It relies on an additional R chunk to print the dataframe/tibble/python-DataFrame/SQL-table. But it does work and it gives a consistent look to all tables in the .qmd -> HTML page, regardless of language.

```{r}
#| echo: false
library(reticulate)
use_virtualenv("./env", required = TRUE)
```


## Set up SQL
```{r}
# R
library(DBI)
library(duckdb)
library(ggplot2)
```

```{r}
# R
## create connection to SQL database
con <- DBI::dbConnect(duckdb::duckdb(), dbdir = "duckdb")
## copy mpg dataset from ggplot2 onto the SQL database, via `con`
dbWriteTable(con, "mpg", ggplot2::mpg, overwrite = TRUE)
```

## Print t…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@emmansh
Comment options

@mcanouil
Comment options

mcanouil Nov 9, 2022
Collaborator

@emmansh
Comment options

@mcanouil
Comment options

mcanouil Nov 9, 2022
Collaborator

Comment options

You must be logged in to vote
0 replies
Answer selected by emmansh
Comment options

You must be logged in to vote
2 replies
@emmansh
Comment options

@cscheid
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants