simpler 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/.gitignore +1 -0
  2. data/README.rdoc +27 -11
  3. data/VERSION +1 -1
  4. metadata +2 -2
data/.gitignore CHANGED
@@ -22,3 +22,4 @@ pkg
22
22
  .RData
23
23
  .Rhistory
24
24
  Rplots.pdf
25
+ *.gemspec
data/README.rdoc CHANGED
@@ -12,23 +12,39 @@ to you.
12
12
 
13
13
  == Examples
14
14
 
15
- require 'simpler'
15
+ FYI - the API is still unstable.
16
16
 
17
- Basic execution (Raw input in, raw input out)
17
+ ==== Basic execution (Raw input, raw output)
18
18
 
19
- sr = Simpler.new
20
- sr.execute!("mean(c(1,2,3))") # -> "[1] 2\n" (a Simpler::Reply object)
19
+ require 'simpler'
20
+ simpler = Simpler.new
21
+ simpler.run!("mean(c(1,2,3))") # -> "[1] 2\n" (a Simpler::Reply object)
21
22
 
22
- Using ruby variables (calculating correlation coefficient):
23
+ ==== Using ruby variables (calculating correlation coefficient):
23
24
 
24
25
  xv = [1,2,7]
25
26
  yv = [3,4,8]
26
- reply = sr.go(xv,yv) do |x,y|
27
- "cor(#{x},#{y})"
28
- end
29
- reply # -> "[1] 0.9994238\n"
27
+ reply = simpler.with(xv,yv) {|x,y| "cor(#{x},#{y})" }.run! # -> "[1] 0.9994238\n"
30
28
 
31
- For plotting on the fly (RScript)
29
+ ==== Show a plot
30
+
31
+ "Rscript" writes plotting commands that would normally go to an X window to "Rplots.pdf". *show!* merely executes your code and opens Rplots.pdf with @pdf_viewer. It's low tech, but it works.
32
+
33
+ simpler.pdf_viewer = "acroread"
34
+ simpler.with(xv,yv) {|x,y| "plot(#{x}, #{y})" }.show!
35
+
36
+ ==== Using DataFrames
37
+
38
+ hash = {
39
+ :one => [1,2,6,7],
40
+ :two => [3,4,2,9],
41
+ :three => [3,1,1,7],
42
+ }
43
+
44
+ df = Simpler::DataFrame.new(hash)
45
+ simpler.with(df) {|d| "plot(#{d})" }.show!
46
+
47
+ DataFrame also supports named rows and specifying directly column names.
32
48
 
33
49
  == Credit
34
50
 
@@ -36,7 +52,7 @@ Simpler is loosely inspired by the original gnuplot and, of course, the excellen
36
52
 
37
53
  ==Casting
38
54
 
39
- All replies are of class Simpler::String, so casting can be done in a way that works for you by defining your own methods.
55
+ All replies are of class Simpler::Reply, so casting can be done in a way that works for you by defining your own methods.
40
56
 
41
57
  == Copyright
42
58
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Prince