Introducing ankiR: Analyze Your Anki Data in R with FSRS Support

If you use Anki for spaced repetition learning, you’ve probably wondered about your study patterns. How many cards have you reviewed? What’s your retention like? Which cards are giving you trouble?

I built ankiR to make this easy in R.

The Problem

Anki stores everything in a SQLite database, but accessing it requires writing raw SQL queries. Python users have ankipandas, but R users had nothing—until now.

Installation

# From GitHub
remotes::install_github("chrislongros/ankiR")

# Arch Linux (AUR)
yay -S r-ankir

Basic Usage

ankiR auto-detects your Anki profile and provides a tidy interface:

library(ankiR)

# See available profiles
anki_profiles()

# Load your data as tibbles
notes <- anki_notes()
cards <- anki_cards()
reviews <- anki_revlog()

# Quick stats
nrow(notes)    # Total notes
nrow(cards)    # Total cards  
nrow(reviews)  # Total reviews

FSRS Support

The killer feature: ankiR extracts FSRS parameters directly from your collection.

FSRS (Free Spaced Repetition Scheduler) is the modern scheduling algorithm in Anki that calculates optimal review intervals based on your memory patterns.

fsrs_cards <- anki_cards_fsrs()

This gives you:

  • stability – memory stability in days (how long until you forget)
  • difficulty – card difficulty on a 1-10 scale
  • retention – your target retention rate (typically 0.9 = 90%)
  • decay – the decay parameter used in calculations

Example: Visualize Your Card Difficulty

library(ankiR)
library(dplyr)
library(ggplot2)

anki_cards_fsrs() |>
  filter(!is.na(difficulty)) |>
  ggplot(aes(difficulty)) +
  geom_histogram(bins = 20, fill = "steelblue") +
  labs(
    title = "Card Difficulty Distribution",
    x = "Difficulty (1-10)",
    y = "Count"
  ) +
  theme_minimal()

Example: Stability vs Difficulty

anki_cards_fsrs() |>
  filter(!is.na(stability)) |>
  ggplot(aes(difficulty, stability)) +
  geom_point(alpha = 0.3, color = "steelblue") +
  scale_y_log10() +
  labs(
    title = "Memory Stability vs Card Difficulty",
    x = "Difficulty",
    y = "Stability (days, log scale)"
  ) +
  theme_minimal()

Example: Review History Over Time

anki_revlog() |>
  count(review_date) |>
  ggplot(aes(review_date, n)) +
  geom_line(color = "steelblue") +
  geom_smooth(method = "loess", se = FALSE, color = "red") +
  labs(
    title = "Daily Review History",
    x = "Date",
    y = "Reviews"
  ) +
  theme_minimal()

Calculate Retrievability

You can also calculate the probability of recalling a card after N days:

# What's my retention after 7 days for a card with 30-day stability?
fsrs_retrievability(stability = 30, days_since_review = 7)
# Returns ~0.93 (93% chance of recall)

Links


I built this because I wanted to analyze my USMLE study data in R. If you find it useful, let me know!


Leave a comment

Discover more from /root

Subscribe now to keep reading and get access to the full archive.

Continue reading