Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made changes to let rinruby work with ruby 2.0.0 and provided additional documentation #22

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
16983a5
normalize whitespace
pitluga May 17, 2016
9bd32b9
remove automatic assignment of R
pitluga May 17, 2016
6d21840
remove method_missing
pitluga May 17, 2016
b3f9722
remove interactive functionality
pitluga May 17, 2016
2181ee1
remove windows support
pitluga May 17, 2016
69779b7
remove jruby support
pitluga May 17, 2016
6ef74a2
tmp - normalize whitespace
pitluga May 17, 2016
96fffe7
clean up tests
pitluga May 17, 2016
43c14cf
better error message when pulling unknown variables
pitluga May 17, 2016
34f0f78
add a capture method to return output as a string
pitluga May 18, 2016
911db17
remove duplicate version variable
pitluga May 18, 2016
f0f8e49
update readme; consistent license
pitluga May 18, 2016
04c9c5b
fork gemspec
pitluga May 18, 2016
431838f
return nil if variable doesn't exist
pitluga May 18, 2016
28e3ea4
bump version to 3.1.0
pitluga May 18, 2016
67b0e10
Added changes in Interface on pull&assign to readme
sebastianzillessen Jun 9, 2016
9627a45
Gitignore updated
sebastianzillessen Jun 9, 2016
dfd98f6
Added Build status to Readme
sebastianzillessen Jun 9, 2016
800d4b2
added ruby 2.2.4 for travis
sebastianzillessen Jun 9, 2016
f44316f
Conditional fixes
sebastianzillessen Jun 9, 2016
3b90056
Added installment of bundler on travis to fix ruby 1.9.3 Specs
sebastianzillessen Jun 9, 2016
08785ee
Added pull_boolean method to be able to pull a boolean
sebastianzillessen Jun 9, 2016
d3767f9
Minor version update
sebastianzillessen Jun 9, 2016
f04f199
Added CodeClimate
sebastianzillessen Jul 17, 2016
c006f65
fixed gemfile
sebastianzillessen Jul 17, 2016
a33eb27
Changed to addons
sebastianzillessen Jul 17, 2016
02dfc4c
Fixed gemfile to old syntax
sebastianzillessen Jul 17, 2016
9f9abc0
Added CodeClimate results to Readme.md
sebastianzillessen Jul 17, 2016
9cb189f
bundler updated
sebastianzillessen Jul 17, 2016
54ca7e7
remooved gemfile.lock
sebastianzillessen Jul 17, 2016
97aede8
Removed ruby support for < 2
sebastianzillessen Jul 17, 2016
73e1cff
added throw message if not defined
sebastianzillessen Jul 20, 2016
3a588bf
new version
sebastianzillessen Jul 20, 2016
1c4a480
fixed spec
sebastianzillessen Jul 20, 2016
6c4cc95
Fixed spec for parsing error
ronnielsen Aug 16, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
pkg
doc
*~
*.gem
.idea/
Gemfile.lock
26 changes: 12 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
language:
ruby

language: ruby
rvm:
- '1.8.7'
- '1.9.3'
- '2.0.0'
- '2.1.1'
- jruby-19mode
# - rbx-2.1.1
script:
bundle exec rspec

- 2.0.0
- 2.1.1
- 2.2.4
- jruby-19mode
script: bundle exec rspec
before_install:
- sudo apt-get update -qq
- sudo apt-get install -y r-base r-base-dev
- sudo apt-get update -qq
- sudo apt-get install -y r-base r-base-dev
- gem install bundler
addons:
code_climate:
repo_token: 4bdb8ebb9430dd415c3145c68b7919a8feec286ed2544168188e61707b908d8a
9 changes: 8 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in rinruby.gemspec
# Specify your gem's dependencies in rootapp-rinruby.gemspec
gemspec

gem 'rake', '~> 10.5.0' if RUBY_VERSION < '1.9.3'
gem 'rake' if RUBY_VERSION >= '1.9.3'

group :test do
gem "codeclimate-test-reporter", :require => nil
end
33 changes: 0 additions & 33 deletions Gemfile.lock

This file was deleted.

84 changes: 37 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,56 @@
# rinruby
* http://rinruby.ddahl.org/

### DESCRIPTION

RinRuby is a Ruby library that integrates the R interpreter in Ruby, making R's statistical routines and graphics available within Ruby. The library consists of a single Ruby script that is simple to install and does not require any special compilation or installation of R. Since the library is 100% pure Ruby, it works on a variety of operating systems, Ruby implementations, and versions of R. RinRuby's methods are simple, making for readable code. The {website [rinruby.ddahl.org]}[http://rinruby.ddahl.org] describes RinRuby usage, provides comprehensive documentation, gives several examples, and discusses RinRuby's implementation.
[![Build Status](https://travis-ci.org/sebastianzillessen/rinruby.svg?branch=master)](https://travis-ci.org/sebastianzillessen/rinruby)
[![Code Climate](https://codeclimate.com/github/sebastianzillessen/rinruby/badges/gpa.svg)](https://codeclimate.com/github/sebastianzillessen/rinruby)
[![Test Coverage](https://codeclimate.com/github/sebastianzillessen/rinruby/badges/coverage.svg)](https://codeclimate.com/github/sebastianzillessen/rinruby/coverage)
[![Issue Count](https://codeclimate.com/github/sebastianzillessen/rinruby/badges/issue_count.svg)](https://codeclimate.com/github/sebastianzillessen/rinruby)

# rinruby

Copyright 2005-2008 David B. Dahl
Execute R code from Ruby.

Developed by David B. Dahl
Documented by David B. Dahl and Scott Crawford
Homepage: http://rinruby.ddahl.org
* Forked from http://rinruby.ddahl.org/

Contributors: Claudio Bustos
### INSTALL

### FEATURES/PROBLEMS
* gem install rootapp-rinruby

* Pure Ruby. Works on Ruby 1.8.7, 1.9 and JRuby 1.4
* Slower than RSRuby, but more robust
### USAGE

### SYNOPSIS

Below is a simple example of RinRuby usage for simple linear regression. The simulation parameters are defined in Ruby, computations are performed in R, and Ruby reports the results. In a more elaborate application, the simulation parameter might come from input from a graphical user interface, the statistical analysis might be more involved, and the results might be an HTML page or PDF report.
```ruby
require "rinruby"

#### Code
R = RinRuby.new

require "rinruby"
n = 10
beta_0 = 1
beta_1 = 0.25
alpha = 0.05
seed = 23423
R.x = (1..n).entries
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
puts "E(y|x) ~= #{R.est[0]} + #{R.est[1]} * x"
if R.pvalue < alpha
puts "Reject the null hypothesis and conclude that x and y are related."
else
puts "There is insufficient evidence to conclude that x and y are related."
end
n = 10
beta_0 = 1
beta_1 = 0.25
alpha = 0.05
seed = 23423
R.assign('x', (1..n).entries)
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
puts "E(y|x) ~= #{R.pull('est')[0]} + #{R.pull('est')[1]} * x"
if R.pull('pvalue') < alpha
puts "Reject the null hypothesis and conclude that x and y are related."
else
puts "There is insufficient evidence to conclude that x and y are related."
end
```

#### Output
**Please note:**

E(y|x) ~= 1.264 + 0.273 * x
Reject the null hypothesis and conclude that x and y are related.
The interface of RinRuby has slightly changed compared to the previous versions.
Variables cannot be assigned directly anymore. But you need to use `assign(name, value)` to assign variables from the ruby side and `pull(name)` to retrieve assigned variables in R in Ruby.

### REQUIREMENTS

* R

### INSTALL

* sudo gem install rinruby


* Ruby >= 2.0.0
### LICENSE

GPL-3. See LICENSE.txt for more information.

19 changes: 4 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
#!/usr/bin/ruby
# -*- ruby -*-
# -*- coding: utf-8 -*-
$:.unshift(File.dirname(__FILE__)+'/lib/')
require 'rubygems'
require 'hoe'
require './lib/rinruby'
# vim: syntax=ruby

Hoe.plugin :git
require "rspec/core/rake_task"

Hoe.spec 'rinruby' do
self.testlib=:rspec
self.version=RinRuby::VERSION
# self.rubyforge_name = 'rinruby' # if different than 'rinruby2'
self.developer('David Dahl', 'rinruby_AT_ddahl.org')
self.developer('Claudio Bustos', 'clbustos_AT_gmail.com')
self.urls = ["http://rinruby.ddahl.org/"]
end
RSpec::Core::RakeTask.new(:spec)

# vim: syntax=ruby
task :default => :spec
Loading