Ruby: Use R in Ruby via “rinruby”!

  >>  sample_size = 10
>>  R.eval “x <- rnorm(#{sample_size})”
>>  R.eval “summary(x)”
>>  R.eval “sd(x)”

With a here document:

require "rinruby"      
#Set all your variables in Ruby
n = 10
beta_0 = 1
beta_1 = 0.25
alpha = 0.05
seed = 23423
R.x = (1..n).entries
#Use actual R code to perform the analysis
R.eval <<EOF
  set.seed(#{seed})
  y <- #{beta_0} + #{beta_1}*x + rnorm(#{n})
  fit <- lm( y ~ x )
  est <- round(coef(fit),3)
  pvalue <- summary(fit)$coefficients[2,4]
EOF