pbosetti-rosar 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +32 -1
- data/lib/rosar.rb +2 -2
- metadata +1 -1
data/README.markdown
CHANGED
@@ -1,4 +1,35 @@
|
|
1
1
|
RosaR
|
2
2
|
=====
|
3
3
|
|
4
|
-
Ruby/OSA R interface
|
4
|
+
Ruby/OSA to Gnu-R interface, useful to plot and analyze data from within ruby.
|
5
|
+
It relies on AppleScript, so only works on Apple OS X (Snow Leopard tested).
|
6
|
+
|
7
|
+
If you have troubles with ruby-osa, install my rubyosa gem:
|
8
|
+
|
9
|
+
sudo gem install pbosetti-rubyosa
|
10
|
+
|
11
|
+
Example
|
12
|
+
=======
|
13
|
+
|
14
|
+
require '../lib/rosar'
|
15
|
+
|
16
|
+
r = ROSAR.instance
|
17
|
+
|
18
|
+
df = {
|
19
|
+
:x => (0..4).to_a,
|
20
|
+
:y => [7,2,5.5,8,9,10]
|
21
|
+
}
|
22
|
+
cols = %w(red green blue darkred darkgreen darkblue)
|
23
|
+
r.transfer :p=>(0...100).to_a
|
24
|
+
r.plot :x=>:p, :y=>"p^2", :typ=>"'l'"
|
25
|
+
2.upto 7 do |i|
|
26
|
+
r.lines :x=>:p, :y=>"#{i}*p^2", :col=>"'#{cols[i-2]}'"
|
27
|
+
end
|
28
|
+
sleep(2)
|
29
|
+
r.data_frame :df, df
|
30
|
+
r.attach :df
|
31
|
+
r.plot :x=>:x, :y=>"y/2", :typ=>"'b'", :col=>"'darkred'", :xlab=>"'Time (s)'"
|
32
|
+
r.grid
|
33
|
+
r.abline :h=>[2.5,3.5]
|
34
|
+
r.abline "a=0, b=1"
|
35
|
+
r.detach :df
|
data/lib/rosar.rb
CHANGED
@@ -61,12 +61,12 @@ class ROSAR
|
|
61
61
|
FIFO = "rosar.fifo"
|
62
62
|
attr_reader :r, :console
|
63
63
|
|
64
|
-
def initialize(r="R")
|
64
|
+
def initialize(hide=true, r="R")
|
65
65
|
@r = OSA.app r
|
66
66
|
self.sync_dir
|
67
67
|
self.activate
|
68
68
|
@console = @r.windows.select {|w| w.name =="R Console"}[0]
|
69
|
-
@console.miniaturized = true
|
69
|
+
@console.miniaturized = true if hide
|
70
70
|
unless FileTest.exists?(FIFO) || FileTest.pipe?(FIFO)
|
71
71
|
`mkfifo #{FIFO}` # something nicer has to be done...
|
72
72
|
end
|