Title: Simulate Typing Script
Version: 0.2.0
Description: Simulates typing of R script files for presentations and demonstrations. Provides character-by-character animation with optional live code execution. Supports R scripts (.R), R Markdown (.Rmd), and Quarto (.qmd) documents.
License: MIT + file LICENSE
Encoding: UTF-8
URL: https://Fgazzelloni.github.io/typeR/, https://github.com/Fgazzelloni/typeR
BugReports: https://github.com/Fgazzelloni/typeR/issues
RoxygenNote: 7.3.3
VignetteBuilder: knitr
Suggests: quarto, testthat (≥ 3.0.0), knitr, rmarkdown
Config/testthat/edition: 3
Imports: stats, utils
Language: en-US
NeedsCompilation: no
Packaged: 2026-02-01 11:47:21 UTC; federicagazzelloni
Author: Federica Gazzelloni [aut, cre]
Maintainer: Federica Gazzelloni <fede.gazzelloni@gmail.com>
Repository: CRAN
Date/Publication: 2026-02-04 17:30:02 UTC

typeR: Simulate Typing Script

Description

logo

Simulates typing of R script files for presentations and demonstrations. Provides character-by-character animation with optional live code execution. Supports R scripts (.R), R Markdown (.Rmd), and Quarto (.qmd) documents.

Author(s)

Maintainer: Federica Gazzelloni fede.gazzelloni@gmail.com

See Also

Useful links:


Simulate Typing of an R Script File

Description

Simulates typing out the content of an R script file, line by line, character by character, to create an animation effect for live coding presentations or educational demonstrations.

Usage

typeR(file, delay = 0.05)

Arguments

file

Path to the R script file to simulate typing.

delay

The delay (in seconds) between typing each character (default: 0.05).

Value

Invisibly returns NULL. Called for the side effect of displaying typed content in the console with animation.

Examples

# Create a temporary R script for demonstration
tmp <- tempfile(fileext = ".R")
writeLines(c(
  "# Example R script",
  "x <- 1:10",
  "mean(x)"
), tmp)

# Simulate typing the script (fast for testing)
typeR(tmp, delay = 0.01)

# Clean up
unlink(tmp)

# Longer example with realistic typing speed

  tmp2 <- tempfile(fileext = ".R")
  writeLines(c(
    "# Data analysis example",
    "data <- mtcars",
    "model <- lm(mpg ~ wt, data = data)",
    "summary(model)"
  ), tmp2)
  typeR(tmp2, delay = 0.08)
  unlink(tmp2)


Type and Run R Code with Live Evaluation

Description

An enhanced version of typeR that not only simulates typing but also evaluates R code in real-time. Supports interactive pause/resume control and handles both Quarto/R Markdown documents and plain R scripts.

Usage

typeRun(
  file,
  delay = 0.05,
  jitter = 0.01,
  max_print = 10,
  envir = new.env(parent = .GlobalEnv)
)

Arguments

file

Character string. Path to an R script (.R), R Markdown (.Rmd), or Quarto (.qmd) file to type and execute.

delay

Numeric. Base delay in seconds between typing each character. Default is 0.05 (50 milliseconds).

jitter

Numeric. Standard deviation for random variation in typing speed, adding natural typing rhythm. Default is 0.01.

max_print

Integer. Maximum number of elements to print for long outputs (vectors, data frames, matrices, lists). Default is 10.

envir

Environment. The environment in which to evaluate R code. Default is a new environment with the global environment as parent.

Details

typeRun() extends the basic typeR() functionality by:

For Quarto/R Markdown files, typeRun():

For R scripts, it evaluates all non-comment, non-empty lines.

Value

Invisibly returns NULL. Called for side effects (typing animation and code evaluation).

Output Handling

Interactive Control

During execution, you can:

  1. Press ESC (or Ctrl+C on some systems) to pause

  2. Enter 1 to resume from where you paused

  3. Enter 2 to stop completely

See Also

typeR for typing without evaluation

Examples

# Create a temporary R script for demonstration
tmp <- tempfile(fileext = ".R")
writeLines(c(
  "# Simple calculation",
  "x <- 1:5",
  "print(mean(x))",
  "y <- x^2",
  "print(sum(y))"
), tmp)

# Type and run with fast animation (for quick testing)

  typeRun(tmp, delay = 0.01, max_print = 5)


# Clean up
unlink(tmp)

# Interactive examples with real files
if (interactive()) {
  # Type and run a simple R script
  typeRun("analysis.R")

  # Type and run with slower, more dramatic effect
  typeRun("demo.R", delay = 0.1, jitter = 0.02)

  # Type and run a Quarto document with limited output
  typeRun("report.qmd", max_print = 5)
}