
Tag: ankiR
-
Unlock insights from your spaced repetition learning journey
If you’re serious about learning, chances are you’ve encountered Anki—the powerful, open-source flashcard application that uses spaced repetition to help you remember anything. Whether you’re studying medicine, languages, programming, or any other subject, Anki has likely become an indispensable part of your learning toolkit.
But have you ever wondered what stories your flashcard data could tell? How your review patterns have evolved over time? Which decks demand the most cognitive effort? That’s exactly why I created ankiR.
What is ankiR?
ankiR is an R package that lets you read, analyze, and visualize your Anki collection data directly in R. Under the hood, Anki stores all your notes, cards, review history, and settings in a SQLite database. ankiR provides a clean, user-friendly interface to access this treasure trove of learning data.
Installation
ankiR is available on CRAN and R-universe, making installation straightforward:
From CRAN
install.packages("ankiR")From R-universe (development version)
# Enable the r-universe repositoryoptions(repos = c(chrislongros = "https://chrislongros.r-universe.dev",CRAN = "https://cloud.r-project.org"))# Install ankiRinstall.packages("ankiR")Key Features
- Read Anki databases: Access your collection.anki2 file or unpack .apkg exports
- Extract review history: Analyze your complete review log (revlog table)
- Access cards and notes: Work with your flashcard content programmatically
- Deck analysis: Examine deck structures and configurations
- Model inspection: Understand your note types and templates
Quick Start Example
Here’s how easy it is to start exploring your Anki data:
library(ankiR)# Connect to your Anki collection# (Find it at ~/.local/share/Anki2/User 1/collection.anki2 on Linux)conn <- read_anki("path/to/collection.anki2")# Get your review historyreviews <- get_revlog(conn)# Analyze review patternslibrary(ggplot2)ggplot(reviews, aes(x = as.Date(as.POSIXct(id/1000, origin = "1970-01-01")))) +geom_histogram(binwidth = 1) +labs(title = "Daily Review Activity",x = "Date",y = "Number of Reviews")# Don't forget to close the connectionclose_anki(conn)Why Analyze Your Anki Data?
Understanding your learning patterns can help you:
- Optimize study habits: Identify your most productive review times
- Track progress: Visualize your learning journey over weeks, months, or years
- Identify problem areas: Find cards or decks with high lapse rates
- Research: Contribute to the growing body of spaced repetition research
- Build custom tools: Create personalized dashboards and reports
Understanding Anki’s Database Structure
For those curious about what’s under the hood, Anki stores data in several tables:
- notes: Your actual flashcard content (fields, tags)
- cards: Individual review items generated from notes
- revlog: Complete history of every review you’ve ever done
- col: Collection metadata, deck configurations, and models
ankiR abstracts away the complexity of parsing JSON-encoded columns and timestamp conversions, giving you clean data frames ready for analysis.
Links and Resources
- CRAN: https://cran.r-project.org/web/packages/ankiR/
- R-universe: https://chrislongros.r-universe.dev/ankiR
- Bug reports: Feel free to open issues on the package repository
Related Projects
If you’re interested in spaced repetition and R, you might also want to check out:
- FSRS: The Free Spaced Repetition Scheduler algorithm, which Anki now supports natively
- anki-snapshot: Git-based version control for Anki collections
Conclusion
Your Anki reviews represent countless hours of deliberate practice. With ankiR, you can finally extract meaningful insights from that data. Whether you’re a medical student tracking board exam prep, a language learner monitoring vocabulary acquisition, or a researcher studying memory, ankiR gives you the tools to understand your learning at a deeper level.
Give it a try, and let me know what insights you discover in your own data!
ankiR is open source and contributions are welcome. Happy learning!
-
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-ankirBasic 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!




