Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created November 22, 2011 20:36
Show Gist options
  • Save thinkerbot/1386858 to your computer and use it in GitHub Desktop.
Save thinkerbot/1386858 to your computer and use it in GitHub Desktop.
R examples
######################################################
# http://www.r-bloggers.com/ascii-scatterplots-in-r/
source("http://biostatmatt.com/R/scat.R")
x <- sin(seq(0,2*pi,length.out=30))
scat(x, cols=15, rows=8)
# ___________________
# | |
# | * |
# | **** |
# | * * |
# | * * |
# | * ** * |
# | * * |
# | * * |
# | **** |
# |___________________|
#
# Normal Distribution
# * 1000 datapoints
# * 100 mean
# * 10 std dev
R --slave -e 'write(rnorm(1000, 100, 10), "", sep = "\\n")'
# https://github.com/holman/spark
R --slave -e 'write(rnorm(1000, 0, 5), "", sep = "\\n")' | cut -d '.' -f 1 | sort -g | uniq -c | sed -e "s/^ \{1,\}//" | cut -d ' ' -f 1 | bash spark.sh
# alternatively
R --slave -e 'write(rnorm(1000, 0, 5), "", sep = "\\n")' | cut -d '.' -f 1 | sort -g | uniq -c | sed -e "s/^ \{1,\}//" | cut -d ' ' -f 1 | ruby -ne 'puts "*" * $_.to_i'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment