exams.forge.data

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library("exams.forge.data")

Sum of Squares Dataset

The package contains the precomputed dataset sos100, which holds integer solutions for:

  1. $\sum_{i=1}^{k} x_i = 0$
  2. $\sum_{i=1}^{k} x_i^2 = 100$

This dataset can be used as a basis for Pearson correlation, linear regression, or other computations requiring integer data with exact sums of squares.

data("sos100")
str(sos100)
# sum_i x_i
head(rowSums(sos100, na.rm=TRUE))
# sum_i x_i^2
head(rowSums(sos100^2, na.rm=TRUE))
# number of non-missing observations
head(rowSums(!is.na(sos100)))

Using sos() for other datasets

For other values of n or different maximum number of summands (nmax), use the sos() function from the exams.forge package:

library("exams.forge")   # version 1.0.12 is required
# Retrieve or compute the dataset for n = 200
sos200 <- sos(200)
# With a custom nmax
sos_custom <- sos(150, nmax = 12)

This function will attempt to load the dataset from the package, a cached location, GitHub, or compute it on the fly if necessary.

Available Exercises

Note:

Exercises:

on Github you can find an overview of all exercises included in the package, organized by topic (directory).

library("knitr")
files <- list.files(path = system.file("aufgaben", package = "exams.forge.data"), pattern = "\\.Rmd$", recursive = TRUE, full.names = FALSE)
tab   <- table(dirname(files))
df    <- data.frame(Topic=names(tab), Exercises=as.integer(tab))               
kable(df, format = "markdown")

Exploring Exercises with view()

The view() function is designed to help users explore and render exercises included in the exams.forge.data package. It provides a fully scriptable interface for browsing topics, listing exercises, and optionally rendering them to PDF or HTML, without relying on interactive menus.

Key Features

  1. List available topics
head(view("topic"))

Returns a character vector of all exercise topics (i.e., subdirectories under aufgaben/). This helps users understand the structure of the exercises and pick a topic of interest.

  1. List exercises in a topic or matching a pattern
head(view("file", pattern = "ttest"))

Returns exercise filenames relative to the subdirectory aufgaben/ in the package.

view("html", pattern = "hyper")

Uses exams2html() to render the selected exercises. Output is silently generated, suppressing messages and warnings.

  1. Render exercises to PDF
view("pdf", pattern = "ttest")

Uses exams2pdf() to render the selected exercises to PDF. A plain LaTeX template is applied, and messages/warnings are suppressed to avoid console clutter.

Parameters

Workflow Example

# 1. List all topics
topics <- view("topic")

# 2. Select exercises from a specific topic
files <- view("file", pattern = "ttest", topic = TRUE)

# 3. Render them to HTML
view("html", pattern = "ttest")

This approach allows users to explore hundreds of exercises efficiently, filter by topic or content, and generate outputs in multiple formats without manual interaction.

Render All Exercises

To render all exercises (on my computer, this takes roughly 1 minute), use the following code:

library("exams.forge")
files <- list.files(path=system.file("aufgaben", package="exams.forge.data"), 
                    pattern="\\.Rmd$", recursive = TRUE, full.names = TRUE)
# Render all 500+ exercises
exams2html(files)   
# Render all exercises as PDF using a custom LaTeX template
# (required because 'exams' does not support \usepackage[xtable]{xcolor})
exams2pdf(files, template=system.file("aufgaben", "plain.tex", package="exams.forge.data"))

Notes:

These warnings are generally harmless and can be safely ignored.



Try the exams.forge.data package in your browser

Any scripts or data that you put into this service are public.

exams.forge.data documentation built on Sept. 11, 2025, 9:09 a.m.