Skip to contents

RXKCD

Authors: Paolo Sonego, Mikko Korpela
License: GPL-2.0
Version: 2.0.1
Status: Stable

rstudio mirror downloads rstudio mirror downloads grand-total

Description

Visualize your favorite XKCD comic strip directly from R. Includes live archive searching with full-text BM25 ranking and semantic similarity search via local GloVe embeddings — all powered by a local DuckDB cache, no external API required.

Installation

The CRAN version can be retrieved with:

The latest version (v2.0.1) can be obtained via:

# install.packages("pak")
pak::pak("onertipaday/RXKCD")

Usage

library(RXKCD)

# First run: downloads all comic metadata, builds FTS index and GloVe embeddings
# Subsequent runs: only syncs new comics
updateConfig()

# Fetch and display a comic
getXKCD("current")       # latest comic
getXKCD("random")        # random comic
getXKCD(353)             # specific comic by number

# Keyword search with BM25 ranking (results ordered by relevance)
searchXKCD("python")
searchXKCD("significant")

# Semantic similarity search using GloVe embeddings
similarXKCD("feeling lonely")
similarXKCD("space exploration", n = 10)

Functions

Function Description
getXKCD(which, display, html, saveImg) Fetch a comic from the live XKCD API. which accepts "current", "random", or a comic number.
updateConfig() Sync local DuckDB cache with new comics, rebuild the FTS index, and retrain GloVe embeddings.
searchXKCD(query) Full-text search across title, alt text, and transcript using BM25 ranking. Returns results with a relevance score.
similarXKCD(query, n = 5) Semantic similarity search using local GloVe embeddings. Returns top n results with a similarity score (0–1).