Skip to content

Instantly share code, notes, and snippets.

@jweslley
Created December 28, 2011 18:52
Show Gist options
  • Save jweslley/1529158 to your computer and use it in GitHub Desktop.
Save jweslley/1529158 to your computer and use it in GitHub Desktop.
ASCII plot
usage(){
echo "Usage: $(basename $0) [-c <cols>] [-r <rows>] [-p <pch>]"
exit 2
}
cols=50
rows=20
pch="*"
while getopts "c:r:p:h" option; do
case "$option" in
c) cols=$OPTARG;;
r) rows=$OPTARG;;
p) pch=$OPTARG;;
h) usage;;
*) usage;;
esac
done
lines=""
while read line
do
test -z "$lines" && lines="$line" || lines="$lines,$line"
done
echo "
source('http://biostatmatt.com/R/scat.R')
scat(c($lines), cols=$cols, rows=$rows, pch='$pch')
" | R --vanilla | tail -$((rows + 5)) | head -$((rows + 3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment