Introduction to Julia for statisticians

RSS International Conference 2025
2 September 2025

Nicola Rennie

About me


Background in statistics, operational research, and data science consultancy.


Data visualisation specialist at the Office for National Statistics.


Co-author of Royal Statistical Society’s Best Practices for Data Visualisation guidance which has examples in R, Python, and Julia.

Screenshot of RSS visualisation guide showing Julia section

What is Julia and why should I care?

What is Julia?


Julia is a high-level, general-purpose, open source programming language.

Julia logo

You might be thinking…

  • I already know a different programming language (like R or Python)…

  • …and I can write code that implements my models…

  • …so why should I spend time learning (yet another) programming language?

The answer: speed

Unlike R and Python, Julia is a compiled language.

  • Interpreted: Translate code into machine language during execution. Great for interactive debugging and user-friendliness but bad for speed.

  • Compiled: Translate code into machine language before running it. Fast.

  • Just in time compilation: Benefits of speed, but without losing the user-friendliness. This is where Julia fits in.

Speed keeps your options open

  • If you’re working with computationally-heavy models, you might struggle to fit them in R.

  • You might need to run code in a different (faster) language.

  • For example, RStan and PyStan interface with Stan for Bayesian inference.

  • You can use Julia in a similar way to give yourself more options.

Stan logo

Getting started with Julia

The first steps

  • Install Julia from julialang.org/install

  • Choose an IDE (VS Code, Positron, …)

  • Check it works! e.g. run Julia in the terminal to start a Julia REPL

Screenshot of Julia REPL

Installing packages

using Pkg
Pkg.add("PalmerPenguins")



Then load the package:

using PalmerPenguins

Penguins cartoon

Collections of packages you might find useful

  • Turing.jl: Bayesian inference with probabilistic programming
    • Turing Organisation has many packages for different things
    • Modelling languages, MCMC, diagnostics, …
  • JuliaGPs: Gaussian Processes in Julia
    • Four core packages
  • JuliaNLSolvers: optimisation functions

Julia packages inspired by R

Tidier.jl

  • Tidier.jl is inspired by R’s ‘tidyverse’ but developed specifically for Julia.
  • Actually a collection of smaller packages, each for performing a specific set of tasks
using Pkg
Pkg.add("Tidier")


Let’s load some data for an example:

using DataFrames
penguins = DataFrame(PalmerPenguins.load());

Tidier.jl logo

Data wrangling

Julia

using TidierData
penguins = @chain penguins begin
  @drop_missing()
  @filter(sex == "female")
  @mutate(body_mass_g = body_mass_g / 1000)
  @select(-bill_depth_mm)
end;

R

library(dplyr)
library(tidyr)
penguins <- penguins |>
  drop_na() |>
  filter(sex == "female") |>
  mutate(body_mass = body_mass / 1000) |>
  select(-bill_dep)

Data visualisation

Julia

using TidierPlots
ggplot(
  penguins, 
  @aes(x = species, y = flipper_length_mm)
) +
  geom_boxplot(@aes(fill = species))

R

library(ggplot2)
ggplot(
  penguins,
  aes(x = species, y = flipper_len)
) +
  geom_boxplot(aes(fill = species))

Combining Julia with other languages

Why combine Julia with another language?

Speed where it matters

  • It’s time consuming to convert all code to a different language
  • Not all code will benefit (much) from a faster language
  • Convert the bottle necks

Maximise user-friendliness

  • Wrap your Julia code into (even more) user-friendly functions in R or Python
  • Introduce your models or functions to a wider audience

See github.com/JuliaInterop.

R & Julia with JuliaCall

JuliaCall is an R package that allows you to run Julia code from R. Load the package and set up Julia:

library(JuliaCall)
julia_setup()


Run code in Julia and use values in R:

y <- julia_eval("sqrt(2)")
y
[1] 1.414214

Run an entire script:

julia_source("script.jl")

R & Julia with JuliaCall

Compute in R and send to Julia:

a <- exp(5)
julia_assign("x", a)


Check it works:

julia_eval("x")
[1] 148.4132


RCall

RCall allows you to call R from Julia. It’s very similar to JuliaCall, but the languages are the other way around.

Python & Julia with PythonCall

  • PythonCall
    • Call Python code from Julia and Julia code from Python via a symmetric interface.
    • Python code looks like Python and the Julia code looks like Julia.

PyCall

PyCall is another library that works in a similar way.

Quarto

  • Quarto is an open-source scientific and technical publishing system.

  • Create reproducible documents, presentations, websites, and books by integrating markdown with code.

  • Native support for multiple languages including both R, Python, and Julia.

Quarto logo

Quarto: combine Julia and R

---
title: "My Julia + R Document"
engine: knitr
---

```{julia}
x = 7 + 9
```

```{r}
plot(1:10, 1:10)
```

Resources

Is Julia for statisticians?




Yes!


  • Speed: speed of C with the ease of R or Python
  • Integration: integrates well with existing workflows in R or Python
  • Community: growing statistical and data science libraries and community