Things I learned: A new TIL

R
Python
Quarto
Published

February 16, 2023

My idea is to keep a more systematic collection of things I learned (TIL).

I was inspired by posts of Simon Wilson and Peter Baumgartner that documented things they have learned.

So here is an initial version and today the TIL has been Quarto.

Here is an example of integrating Tidyverse-R code.

library(tidyverse)

mtcars <- as_tibble(datasets::mtcars)

ggplot(mtcars, aes(x = hp, y = mpg)) +
  geom_point(aes(color = factor(cyl))) +
  geom_smooth()

Here is an example of integrating Python code.

import statsmodels.api as sm
import pandas as pd

mtcars = sm.datasets.get_rdataset('mtcars').data

mtcars.plot(x = "hp", y = "mpg", kind = "scatter")

Some background

Setting up a blog in Quarto was easy and well documented. So I started quickly.

Getting the right Python version running in Quarto was quite a challenge. At the end, the documented recommendation to work with a virtual environment in an env folder worked. It took me some time to get there.

It only worked temporarily and I will try to run Python in Quarto again at some later point.

Afterwards

It turned out that the particular challenge was having a page with R and Python.

For Python pages a header option was missing. jupyter: python3 solved the Python challenge that took quite some time.

Rendering a Quarto document with R and Python was only possible with a version Docker on the computer.