Skip to content

Instantly share code, notes, and snippets.

@nylander
Last active August 14, 2025 17:24
Show Gist options
  • Save nylander/a418b571f0953b33c67453f1aa6cc52a to your computer and use it in GitHub Desktop.
Save nylander/a418b571f0953b33c67453f1aa6cc52a to your computer and use it in GitHub Desktop.
Summarize integer values from stdin using R
#!/usr/bin/env Rscript
# File: summary
# Description: Summarize data from stdin as min, max, mean, median
# Requirements: R
# Usage example: for i in $(seq 1 100); do echo $RANDOM; done | summary
# 288 32697 14644.19 14256
a <- scan(file("stdin"), c(0), quiet=TRUE);
cat(min(a), max(a), mean(a), median(a), "\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment