rosar 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +16 -2
- data/lib/rosar.rb +8 -16
- data/test/rtest.rb +2 -5
- metadata +40 -41
data/README.markdown
CHANGED
@@ -4,9 +4,23 @@ RosaR
|
|
4
4
|
Ruby/OSA to Gnu-R interface, useful to plot and analyze data from within ruby.
|
5
5
|
It relies on AppleScript, so only works on Apple OS X (Snow Leopard tested).
|
6
6
|
|
7
|
-
|
7
|
+
Installation
|
8
|
+
============
|
9
|
+
RosaR gem has moved to [Gemcutter](http://gemcutter.org). In order to install you have two **alternative** choices:
|
8
10
|
|
9
|
-
|
11
|
+
1. Simply add the Gemcutter repo to your rubygem source list:
|
12
|
+
|
13
|
+
gem sources -a http://gemcutter.org
|
14
|
+
|
15
|
+
2. Install gemcutter:
|
16
|
+
|
17
|
+
sudo gem install gemcutter
|
18
|
+
sudo gem tumble
|
19
|
+
|
20
|
+
Next, simply install the gem:
|
21
|
+
|
22
|
+
sudo gem install rosar
|
23
|
+
|
10
24
|
|
11
25
|
Example
|
12
26
|
=======
|
data/lib/rosar.rb
CHANGED
@@ -5,8 +5,7 @@
|
|
5
5
|
# reserved.
|
6
6
|
require 'singleton'
|
7
7
|
require 'rubygems'
|
8
|
-
require
|
9
|
-
|
8
|
+
require "rubyosa"
|
10
9
|
|
11
10
|
=begin rdoc
|
12
11
|
Adds a to_r method to standara Arrays, which returns a String representation
|
@@ -58,17 +57,14 @@ end
|
|
58
57
|
=end
|
59
58
|
class ROSAR
|
60
59
|
include Singleton
|
61
|
-
|
60
|
+
EXCHANGE = "rosar.exc"
|
62
61
|
attr_reader :r, :console
|
63
62
|
|
64
|
-
def initialize(r="
|
63
|
+
def initialize(r="R64")
|
65
64
|
@r = OSA.app r
|
66
65
|
self.sync_dir
|
67
66
|
self.activate
|
68
|
-
@console = @r.windows.select {|w| w.name =="R Console"}[0]
|
69
|
-
unless FileTest.exists?(FIFO) || FileTest.pipe?(FIFO)
|
70
|
-
`mkfifo #{FIFO}` # something nicer has to be done...
|
71
|
-
end
|
67
|
+
# @console = @r.windows.select {|w| w.name =="R Console"}[0]
|
72
68
|
end
|
73
69
|
|
74
70
|
def minimize
|
@@ -108,12 +104,8 @@ class ROSAR
|
|
108
104
|
Transfers the Hash of Arrays +df+ to a dataframe named +name+. Uses a FIFO
|
109
105
|
to move values around.
|
110
106
|
=end
|
111
|
-
def data_frame(name, df)
|
112
|
-
|
113
|
-
@r.cmd "#{name}<-read.table('#{FIFO}', h=T)"
|
114
|
-
end
|
115
|
-
|
116
|
-
File.open("#{FIFO}", "w") do |f|
|
107
|
+
def data_frame(name, df, keep=false)
|
108
|
+
File.open("#{EXCHANGE}", "w") do |f|
|
117
109
|
f.puts df.keys*"\t"
|
118
110
|
df[df.keys[0]].size.times do |i|
|
119
111
|
df.each_key do |k|
|
@@ -122,8 +114,8 @@ class ROSAR
|
|
122
114
|
f.puts
|
123
115
|
end
|
124
116
|
end
|
125
|
-
|
126
|
-
|
117
|
+
@r.cmd "#{name}<-read.table('#{EXCHANGE}', h=T)"
|
118
|
+
@r.cmd "unlink(\"#{EXCHANGE}\")" unless keep
|
127
119
|
end
|
128
120
|
|
129
121
|
=begin rdoc
|
data/test/rtest.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
##!/usr/bin/env ruby
|
2
2
|
#
|
3
3
|
# Created by Paolo Bosetti on 2008-05-27.
|
4
4
|
# Copyright (c) 2008 University of Trento. All rights
|
@@ -7,10 +7,7 @@
|
|
7
7
|
require '../lib/rosar'
|
8
8
|
|
9
9
|
r = ROSAR.instance
|
10
|
-
df = {
|
11
|
-
:x => (0..4).to_a,
|
12
|
-
:y => [7,2,5.5,8,9,10]
|
13
|
-
}
|
10
|
+
df = {:x => (0..4).to_a,:y => [7,2,5.5,8,9,10]}
|
14
11
|
cols = %w(red green blue darkred darkgreen darkblue)
|
15
12
|
r.transfer :p=>(0...100).to_a
|
16
13
|
r.plot :x=>:p, :y=>"p^2", :typ=>"'l'"
|
metadata
CHANGED
@@ -1,67 +1,66 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rosar
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Paolo Bosetti
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
date: 2012-04-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rubyosa19
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.5.0
|
17
22
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
description: Ruby/GNU-R interface that uses OSA under OS X.
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.5.0
|
30
|
+
description: Ruby/GNU-R interface that uses OSA under OS X, compatible with Ruby 1.9.x.
|
26
31
|
email: paolo.bosetti@me.com
|
27
32
|
executables: []
|
28
|
-
|
29
33
|
extensions: []
|
30
|
-
|
31
34
|
extra_rdoc_files: []
|
32
|
-
|
33
|
-
files:
|
35
|
+
files:
|
34
36
|
- README.markdown
|
35
37
|
- lib/rosar.rb
|
36
38
|
- test/rtest.rb
|
37
|
-
has_rdoc: true
|
38
39
|
homepage: http://github.com/pbosetti/flotr
|
39
40
|
licenses: []
|
40
|
-
|
41
41
|
post_install_message:
|
42
|
-
rdoc_options:
|
42
|
+
rdoc_options:
|
43
43
|
- --inline-source
|
44
44
|
- --charset=UTF-8
|
45
|
-
require_paths:
|
45
|
+
require_paths:
|
46
46
|
- lib
|
47
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
59
|
requirements: []
|
60
|
-
|
61
60
|
rubyforge_project: rosar
|
62
|
-
rubygems_version: 1.
|
61
|
+
rubygems_version: 1.8.21
|
63
62
|
signing_key:
|
64
63
|
specification_version: 2
|
65
64
|
summary: Ruby/GNU-R interface that uses OSA under OS X.
|
66
65
|
test_files: []
|
67
|
-
|
66
|
+
has_rdoc: true
|