simpler 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/README.rdoc +27 -11
- data/VERSION +1 -1
- metadata +2 -2
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -12,23 +12,39 @@ to you.
|
|
12
12
|
|
13
13
|
== Examples
|
14
14
|
|
15
|
-
|
15
|
+
FYI - the API is still unstable.
|
16
16
|
|
17
|
-
Basic execution (Raw input
|
17
|
+
==== Basic execution (Raw input, raw output)
|
18
18
|
|
19
|
-
|
20
|
-
|
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 =
|
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
|
-
|
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::
|
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
|
+
0.0.2
|