scicom 0.2.0-java
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.
- checksums.yaml +7 -0
- data/LICENSE.txt +674 -0
- data/README.md +66 -0
- data/README.md~ +290 -0
- data/Rakefile +51 -0
- data/config.rb +163 -0
- data/doc/PypeR.pdf +0 -0
- data/doc/Stat 133 Class Notes (Phil Spector).pdf +29905 -45
- data/doc/The R interface.docx +0 -0
- data/lib/JRubyR/as_mdarray.rb +60 -0
- data/lib/JRubyR/attributes.rb +74 -0
- data/lib/JRubyR/dataframe.rb +35 -0
- data/lib/JRubyR/environment.rb +60 -0
- data/lib/JRubyR/function.rb +61 -0
- data/lib/JRubyR/index.rb +278 -0
- data/lib/JRubyR/list.rb +56 -0
- data/lib/JRubyR/list_orig.rb +111 -0
- data/lib/JRubyR/logical_value.rb +56 -0
- data/lib/JRubyR/rbsexp.rb +386 -0
- data/lib/JRubyR/renjin.rb +431 -0
- data/lib/JRubyR/ruby_classes.rb +58 -0
- data/lib/JRubyR/sequence.rb +56 -0
- data/lib/JRubyR/vector.rb +493 -0
- data/lib/env.rb +12 -0
- data/lib/rinruby.rb +795 -0
- data/lib/scicom.rb +29 -0
- data/target/helper.jar +0 -0
- data/test/baseball.csv +1 -0
- data/test/env.rb +7 -0
- data/test/test_R_interface.rb +165 -0
- data/test/test_array.rb +191 -0
- data/test/test_attributes.rb +261 -0
- data/test/test_basic.rb +156 -0
- data/test/test_column-major.rb +114 -0
- data/test/test_complete.rb +49 -0
- data/test/test_creation.rb +299 -0
- data/test/test_dataframe.rb +248 -0
- data/test/test_distribution.rb +320 -0
- data/test/test_double_assign.rb +240 -0
- data/test/test_double_receive.rb +106 -0
- data/test/test_environment.rb +57 -0
- data/test/test_factor.rb +285 -0
- data/test/test_functions.rb +67 -0
- data/test/test_linear_model.rb +64 -0
- data/test/test_list.rb +220 -0
- data/test/test_matrix.rb +205 -0
- data/test/test_mdarray.rb +258 -0
- data/test/test_operators.rb +227 -0
- data/test/test_sequence.rb +63 -0
- data/test/test_subsetting.rb +67 -0
- data/test/test_tmp.rb +67 -0
- data/test/test_vector.rb +227 -0
- data/vendor/Renjin.pdf +0 -0
- data/vendor/renjin-script-engine-0.7.0-RC7-SNAPSHOT-jar-with-dependencies.jar +0 -0
- data/version.rb +2 -0
- metadata +196 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
##########################################################################################
|
4
|
+
# Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
5
|
+
# and distribute this software and its documentation, without fee and without a signed
|
6
|
+
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
7
|
+
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
8
|
+
# distributions.
|
9
|
+
#
|
10
|
+
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
11
|
+
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
12
|
+
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
13
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
14
|
+
#
|
15
|
+
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
16
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
17
|
+
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
18
|
+
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
19
|
+
# OR MODIFICATIONS.
|
20
|
+
##########################################################################################
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require "test/unit"
|
24
|
+
require 'shoulda'
|
25
|
+
|
26
|
+
require 'env'
|
27
|
+
require 'scicom'
|
28
|
+
|
29
|
+
class SciComTest < Test::Unit::TestCase
|
30
|
+
|
31
|
+
context "R environment" do
|
32
|
+
|
33
|
+
#======================================================================================
|
34
|
+
#
|
35
|
+
#======================================================================================
|
36
|
+
|
37
|
+
setup do
|
38
|
+
|
39
|
+
# creating a new instance of Renjin
|
40
|
+
@r1 = R.new
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
#======================================================================================
|
45
|
+
#
|
46
|
+
#======================================================================================
|
47
|
+
|
48
|
+
should "create an int sequence" do
|
49
|
+
|
50
|
+
seq = R.seq(2, 10)
|
51
|
+
|
52
|
+
res = R.eval <<EOF
|
53
|
+
print(#{seq.r});
|
54
|
+
print(#{seq.r});
|
55
|
+
print(ls());
|
56
|
+
|
57
|
+
EOF
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
##########################################################################################
|
4
|
+
# Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
5
|
+
# and distribute this software and its documentation, without fee and without a signed
|
6
|
+
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
7
|
+
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
8
|
+
# distributions.
|
9
|
+
#
|
10
|
+
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
11
|
+
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
12
|
+
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
13
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
14
|
+
#
|
15
|
+
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
16
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
17
|
+
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
18
|
+
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
19
|
+
# OR MODIFICATIONS.
|
20
|
+
##########################################################################################
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require "test/unit"
|
24
|
+
require 'shoulda'
|
25
|
+
|
26
|
+
require 'env'
|
27
|
+
require 'scicom'
|
28
|
+
|
29
|
+
class SciComTest < Test::Unit::TestCase
|
30
|
+
|
31
|
+
context "R Vectors" do
|
32
|
+
|
33
|
+
#--------------------------------------------------------------------------------------
|
34
|
+
#
|
35
|
+
#--------------------------------------------------------------------------------------
|
36
|
+
|
37
|
+
setup do
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
#--------------------------------------------------------------------------------------
|
43
|
+
#
|
44
|
+
#--------------------------------------------------------------------------------------
|
45
|
+
|
46
|
+
should "slice a vector in multiple ways" do
|
47
|
+
|
48
|
+
vec = R.c(1, 2, 3, 4)
|
49
|
+
|
50
|
+
# access a given vector index
|
51
|
+
assert_equal(3, vec[3].gz)
|
52
|
+
|
53
|
+
# Method .gt gets the thruth value of the first element of the array
|
54
|
+
# Vector with negative index: all values are returned but the ones in the index
|
55
|
+
assert_equal(true, (R.c(1, 2, 4).eq vec[-3]).gt)
|
56
|
+
|
57
|
+
# New vector in the given range
|
58
|
+
assert_equal(true, (R.c(1, 2, 3).eq vec[(1..3)]).gt)
|
59
|
+
|
60
|
+
|
61
|
+
vec[-(1..3)].pp
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
data/test/test_tmp.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
##########################################################################################
|
4
|
+
# Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
5
|
+
# and distribute this software and its documentation, without fee and without a signed
|
6
|
+
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
7
|
+
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
8
|
+
# distributions.
|
9
|
+
#
|
10
|
+
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
11
|
+
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
12
|
+
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
13
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
14
|
+
#
|
15
|
+
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
16
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
17
|
+
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
18
|
+
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
19
|
+
# OR MODIFICATIONS.
|
20
|
+
##########################################################################################
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require "test/unit"
|
24
|
+
require 'shoulda'
|
25
|
+
|
26
|
+
require 'env'
|
27
|
+
require 'scicom'
|
28
|
+
|
29
|
+
class SciComTest < Test::Unit::TestCase
|
30
|
+
|
31
|
+
context "R environment" do
|
32
|
+
|
33
|
+
#--------------------------------------------------------------------------------------
|
34
|
+
#
|
35
|
+
#--------------------------------------------------------------------------------------
|
36
|
+
|
37
|
+
setup do
|
38
|
+
|
39
|
+
# create a list with named elements
|
40
|
+
@x = R.list(first: (1..10), second: R.c("yes","no"), third: R.c(TRUE,FALSE),
|
41
|
+
fourth: R.gl(2,3))
|
42
|
+
|
43
|
+
@seq = R.c((1..10))
|
44
|
+
@seq2 = R.c((1...10))
|
45
|
+
@str_vec = R.c("yes", "no")
|
46
|
+
@str_vec2 = R.c("yes", "yes")
|
47
|
+
@trth_vec = R.c(TRUE, FALSE)
|
48
|
+
@trth_vec2 = R.c(FALSE, FALSE)
|
49
|
+
@gl = R.gl(2, 3)
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
#--------------------------------------------------------------------------------------
|
54
|
+
#
|
55
|
+
#--------------------------------------------------------------------------------------
|
56
|
+
|
57
|
+
should "assign to a character vector" do
|
58
|
+
|
59
|
+
h = {f: :colnames, index: [[1]]}
|
60
|
+
p h[:f]
|
61
|
+
p h[:index]
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
data/test/test_vector.rb
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
##########################################################################################
|
4
|
+
# Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
5
|
+
# and distribute this software and its documentation, without fee and without a signed
|
6
|
+
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
7
|
+
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
8
|
+
# distributions.
|
9
|
+
#
|
10
|
+
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
11
|
+
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
12
|
+
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
13
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
14
|
+
#
|
15
|
+
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
16
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
17
|
+
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
18
|
+
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
19
|
+
# OR MODIFICATIONS.
|
20
|
+
##########################################################################################
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require "test/unit"
|
24
|
+
require 'shoulda'
|
25
|
+
|
26
|
+
require 'env'
|
27
|
+
require 'scicom'
|
28
|
+
|
29
|
+
class SciComTest < Test::Unit::TestCase
|
30
|
+
|
31
|
+
context "R Vectors" do
|
32
|
+
|
33
|
+
#--------------------------------------------------------------------------------------
|
34
|
+
#
|
35
|
+
#--------------------------------------------------------------------------------------
|
36
|
+
|
37
|
+
setup do
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
#--------------------------------------------------------------------------------------
|
42
|
+
#
|
43
|
+
#--------------------------------------------------------------------------------------
|
44
|
+
|
45
|
+
should "create vectors of different types" do
|
46
|
+
|
47
|
+
# double vector
|
48
|
+
dbl_var = R.c(1, 2.5, 4.5)
|
49
|
+
assert_equal(2.5, dbl_var[2].gz)
|
50
|
+
assert_equal("double", dbl_var.typeof.gz)
|
51
|
+
assert_equal(3, dbl_var.length)
|
52
|
+
assert_equal(false, dbl_var.integer?)
|
53
|
+
assert_equal(true, dbl_var.double?)
|
54
|
+
assert_equal(true, dbl_var.numeric?)
|
55
|
+
|
56
|
+
# int vector: with the R.i, you get an integer rather than a double
|
57
|
+
int_var = R.c(R.i(1), R.i(6), R.i(10))
|
58
|
+
assert_equal("integer", int_var.typeof.gz)
|
59
|
+
assert_equal(3, int_var.length)
|
60
|
+
assert_equal(true, int_var.integer?)
|
61
|
+
|
62
|
+
# logical vector: Use TRUE and FALSE to create logical vectors
|
63
|
+
log_var = R.c(TRUE, FALSE, TRUE, FALSE)
|
64
|
+
assert_equal("logical", log_var.typeof.gz)
|
65
|
+
assert_equal(4, log_var.length)
|
66
|
+
assert_equal(true, log_var.logical?)
|
67
|
+
|
68
|
+
# string vector: create string (character) vectors
|
69
|
+
chr_var = R.c("these are", "some strings")
|
70
|
+
assert_equal("character", chr_var.typeof.gz)
|
71
|
+
assert_equal(2, chr_var.length)
|
72
|
+
assert_equal(true, chr_var.character?)
|
73
|
+
assert_equal(true, chr_var.atomic?)
|
74
|
+
assert_equal(false, chr_var.numeric?)
|
75
|
+
|
76
|
+
# complex vector
|
77
|
+
comp_var = R.c(R.complex(real: 2, imaginary: 1), R.complex(real: 0, imaginary: 1))
|
78
|
+
assert_equal("complex", comp_var.typeof.gz)
|
79
|
+
assert_equal(2, comp_var.length)
|
80
|
+
assert_equal(false, comp_var.integer?)
|
81
|
+
assert_equal(false, comp_var.double?)
|
82
|
+
assert_equal(true, comp_var.complex?)
|
83
|
+
assert_equal(1, comp_var[2].im.gz)
|
84
|
+
|
85
|
+
## create a complex normal vector
|
86
|
+
z = R.complex(real: R.rnorm(100), imaginary: R.rnorm(100))
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
#--------------------------------------------------------------------------------------
|
91
|
+
#
|
92
|
+
#--------------------------------------------------------------------------------------
|
93
|
+
|
94
|
+
should "create vectors with basic R functions" do
|
95
|
+
|
96
|
+
# R.c "flattens" the vectors
|
97
|
+
v1 = R.c(1, R.c(2, R.c(3, 4)))
|
98
|
+
assert_equal(true, (R.c(1, 2, 3, 4).eq v1).gt)
|
99
|
+
|
100
|
+
# R.rep repeats the given vector
|
101
|
+
vec2 = R.rep(R.c("A", "B", "C"), 3)
|
102
|
+
assert_equal(true, (R.c("A", "B", "C", "A", "B", "C", "A", "B", "C").eq vec2).gt)
|
103
|
+
|
104
|
+
# R.table calculates the frequencies of elements
|
105
|
+
vec3 = R.c("A", "B", "C", "A", "A", "A", "A", "B", "B")
|
106
|
+
table = R.table(vec3)
|
107
|
+
assert_equal(true, (R.c(R.i(5), R.i(3), R.i(1)) == table).gt)
|
108
|
+
|
109
|
+
# Ruby does not allow the ":" notation such as "1:3", this can be obtained
|
110
|
+
# by Ruby's range notation (1..3) or (1...3)
|
111
|
+
# does not include the last element
|
112
|
+
v2 = R.c((1...3))
|
113
|
+
assert_equal(true, (R.c(1, 2) == v2).gt)
|
114
|
+
|
115
|
+
# includes the last element
|
116
|
+
v3 = R.c((1..3))
|
117
|
+
assert_equal(true, (R.c(1, 2, 3) == v3).gt)
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
#--------------------------------------------------------------------------------------
|
122
|
+
#
|
123
|
+
#--------------------------------------------------------------------------------------
|
124
|
+
|
125
|
+
should "access vector elements" do
|
126
|
+
|
127
|
+
i1 = R.i(10)
|
128
|
+
# In R, and with SciCom vectors, indexing a vector returns a vector. First index for
|
129
|
+
# vector is 1 and not 0 as it is usual with Ruby, this is so, in order to be
|
130
|
+
# consistent with R.
|
131
|
+
i3 = i1[1]
|
132
|
+
assert_equal(true, (i3 == i1).gt)
|
133
|
+
|
134
|
+
# double vector
|
135
|
+
dbl_var = R.c(1, 2.5, 4.5)
|
136
|
+
assert_equal(2.5, dbl_var[2].gz)
|
137
|
+
assert_equal(4.5, dbl_var[3].gz)
|
138
|
+
|
139
|
+
# indexing a vector outside of bound returns NA
|
140
|
+
assert_equal(NA, dbl_var[4].gz)
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
#--------------------------------------------------------------------------------------
|
145
|
+
#
|
146
|
+
#--------------------------------------------------------------------------------------
|
147
|
+
|
148
|
+
should "assign to a numeric vector" do
|
149
|
+
|
150
|
+
# assign to a given vector index
|
151
|
+
vec = R.c(1, 2, 3)
|
152
|
+
vec[1] = 0
|
153
|
+
assert_equal(true, (R.c(0, 2, 3) == vec).gt)
|
154
|
+
|
155
|
+
# assign to a vector slice
|
156
|
+
vec[R.c(1, 2)] = R.c(5, 6)
|
157
|
+
assert_equal(true, (R.c(5, 6, 3) == vec).gt)
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
#--------------------------------------------------------------------------------------
|
162
|
+
#
|
163
|
+
#--------------------------------------------------------------------------------------
|
164
|
+
|
165
|
+
should "assign to a character vector" do
|
166
|
+
|
167
|
+
vec = R.c("a", "b", "c")
|
168
|
+
vec[1] = "d"
|
169
|
+
assert_equal(true, (R.c("d", "b", "c").eq vec).gt)
|
170
|
+
|
171
|
+
# assign to a vector slice
|
172
|
+
vec[R.c(1, 2)] = R.c("e", "f")
|
173
|
+
assert_equal(true, (R.c("e", "f", "c").eq vec).gt)
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
#--------------------------------------------------------------------------------------
|
178
|
+
#
|
179
|
+
#--------------------------------------------------------------------------------------
|
180
|
+
|
181
|
+
should "match two vectors with %in%" do
|
182
|
+
|
183
|
+
vec1 = R.c(1, 2, 3, 4)
|
184
|
+
vec2 = R.c(1, 2, 3, 4)
|
185
|
+
vec3 = R.c(3, 4, 5)
|
186
|
+
vec4 = R.c(4, 5, 6, 7)
|
187
|
+
|
188
|
+
# R has functions defined with '%%' notation. In order to access those functions
|
189
|
+
# from SciCom we use the '._' method with two arguments, the first argument is the
|
190
|
+
# name of the function, for instance, function %in%, the name of the method is ':in'
|
191
|
+
# Ex: vec1 %in% vec2 => vec1._ :in, vec2
|
192
|
+
(vec1._ :in, vec2).pp
|
193
|
+
(vec1._ :in, vec3).pp
|
194
|
+
(vec2._ :in, vec4).pp
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
#--------------------------------------------------------------------------------------
|
199
|
+
#
|
200
|
+
#--------------------------------------------------------------------------------------
|
201
|
+
|
202
|
+
should "Apply a Function over a List or Vector" do
|
203
|
+
|
204
|
+
x = R.list(a: (1..10), beta: R.exp(-3..3), logic: R.c(TRUE,FALSE,FALSE,TRUE))
|
205
|
+
x.pp
|
206
|
+
# compute the list mean for each list element
|
207
|
+
mean = R.lapply(x, "mean")
|
208
|
+
mean.pp
|
209
|
+
|
210
|
+
# median and quartiles for each list element
|
211
|
+
# quant = R.lapply(x, "quantile")
|
212
|
+
# quant = R.sapply(x, "quantile")
|
213
|
+
# quant.pp
|
214
|
+
# R.eval("x <- lapply(#{x.r}, quantile, c(0.25, 0.50, 0.75))")
|
215
|
+
# R.eval("print(x)")
|
216
|
+
|
217
|
+
# list of vectors
|
218
|
+
i39 = R.sapply((3..9), "seq")
|
219
|
+
i39.pp
|
220
|
+
sap = R.sapply(i39, "fivenum")
|
221
|
+
sap.pp
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
data/vendor/Renjin.pdf
ADDED
Binary file
|
data/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scicom
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- Rodrigo Botafogo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: shoulda
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '0'
|
25
|
+
prerelease: false
|
26
|
+
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: simplecov
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.1
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 0.7.1
|
39
|
+
prerelease: false
|
40
|
+
type: :development
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: yard
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.8.5.2
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.8.5.2
|
53
|
+
prerelease: false
|
54
|
+
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: kramdown
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.1
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.0.1
|
67
|
+
prerelease: false
|
68
|
+
type: :development
|
69
|
+
description: "SciCom (Scientific Computing) for Ruby brings the power of R to the\
|
70
|
+
\ Ruby community. SciCom \nis based on Renjin, a JVM-based interpreter for the R\
|
71
|
+
\ language for statistical computing.\n\nR on the JVM\n------------\n\nOver the\
|
72
|
+
\ past two decades, the R language for statistical computing has emerged as the\
|
73
|
+
\ de \nfacto standard for analysts, statisticians, and scientists. Today, a wide\
|
74
|
+
\ range of \nenterprises – from pharmaceuticals to insurance – depend on R for key\
|
75
|
+
\ business uses. Renjin \nis a new implementation of the R language and environment\
|
76
|
+
\ for the Java Virtual Machine (JVM),\nwhose goal is to enable transparent analysis\
|
77
|
+
\ of big data sets and seamless integration with \nother enterprise systems such\
|
78
|
+
\ as databases and application servers.\n\nRenjin is still under development, but\
|
79
|
+
\ it is already being used in production for a number \nof client projects, and\
|
80
|
+
\ supports most CRAN packages, including some with C/Fortran \ndependencies.\n\n\
|
81
|
+
SciCom and Renjin\n-----------------\n\nSciCom integrates with Renjin and allows\
|
82
|
+
\ the use of R inside a Ruby script. In a sense, \nSciCom is similar to other solutions\
|
83
|
+
\ such as RinRuby, Rpy2, PipeR, etc. However, since \nSciCom and Renjin both target\
|
84
|
+
\ the JVM there is no need to integrate both solutions and \nthere is no need to\
|
85
|
+
\ send data between Ruby and R, as it all resides in the same JVM. \nFurther, installation\
|
86
|
+
\ of SciCom does not require the installation of GNU R; Renjin is the \ninterpreter\
|
87
|
+
\ and comes with SciCom. Finally, although SciCom provides a basic interface to\
|
88
|
+
\ \nRenjin similar to RinRuby, a much tighter integration is also possible.\n"
|
89
|
+
email: rodrigo.a.botafogo@gmail.com
|
90
|
+
executables: []
|
91
|
+
extensions: []
|
92
|
+
extra_rdoc_files: []
|
93
|
+
files:
|
94
|
+
- Rakefile
|
95
|
+
- version.rb
|
96
|
+
- config.rb
|
97
|
+
- lib/env.rb
|
98
|
+
- lib/rinruby.rb
|
99
|
+
- lib/scicom.rb
|
100
|
+
- lib/JRubyR/list.rb
|
101
|
+
- lib/JRubyR/vector.rb
|
102
|
+
- lib/JRubyR/attributes.rb
|
103
|
+
- lib/JRubyR/as_mdarray.rb
|
104
|
+
- lib/JRubyR/logical_value.rb
|
105
|
+
- lib/JRubyR/sequence.rb
|
106
|
+
- lib/JRubyR/environment.rb
|
107
|
+
- lib/JRubyR/list_orig.rb
|
108
|
+
- lib/JRubyR/ruby_classes.rb
|
109
|
+
- lib/JRubyR/function.rb
|
110
|
+
- lib/JRubyR/index.rb
|
111
|
+
- lib/JRubyR/rbsexp.rb
|
112
|
+
- lib/JRubyR/renjin.rb
|
113
|
+
- lib/JRubyR/dataframe.rb
|
114
|
+
- test/env.rb
|
115
|
+
- test/test_tmp.rb
|
116
|
+
- test/test_attributes.rb
|
117
|
+
- test/test_complete.rb
|
118
|
+
- test/test_column-major.rb
|
119
|
+
- test/test_double_assign.rb
|
120
|
+
- test/test_double_receive.rb
|
121
|
+
- test/test_distribution.rb
|
122
|
+
- test/test_creation.rb
|
123
|
+
- test/test_array.rb
|
124
|
+
- test/test_sequence.rb
|
125
|
+
- test/test_environment.rb
|
126
|
+
- test/test_functions.rb
|
127
|
+
- test/test_basic.rb
|
128
|
+
- test/test_vector.rb
|
129
|
+
- test/test_mdarray.rb
|
130
|
+
- test/test_subsetting.rb
|
131
|
+
- test/test_factor.rb
|
132
|
+
- test/test_R_interface.rb
|
133
|
+
- test/test_operators.rb
|
134
|
+
- test/test_linear_model.rb
|
135
|
+
- test/test_matrix.rb
|
136
|
+
- test/test_dataframe.rb
|
137
|
+
- test/test_list.rb
|
138
|
+
- test/baseball.csv
|
139
|
+
- doc/PypeR.pdf
|
140
|
+
- doc/The R interface.docx
|
141
|
+
- doc/Stat 133 Class Notes (Phil Spector).pdf
|
142
|
+
- vendor/renjin-script-engine-0.7.0-RC7-SNAPSHOT-jar-with-dependencies.jar
|
143
|
+
- vendor/Renjin.pdf
|
144
|
+
- target/helper.jar
|
145
|
+
- README.md
|
146
|
+
- README.md~
|
147
|
+
- LICENSE.txt
|
148
|
+
homepage: http://github.com/rbotafogo/scicom/wiki
|
149
|
+
licenses:
|
150
|
+
- GPL
|
151
|
+
metadata: {}
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
requirements: []
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.1.9
|
169
|
+
signing_key:
|
170
|
+
specification_version: 4
|
171
|
+
summary: Scientific Computing for Ruby
|
172
|
+
test_files:
|
173
|
+
- test/env.rb
|
174
|
+
- test/test_tmp.rb
|
175
|
+
- test/test_attributes.rb
|
176
|
+
- test/test_complete.rb
|
177
|
+
- test/test_column-major.rb
|
178
|
+
- test/test_double_assign.rb
|
179
|
+
- test/test_double_receive.rb
|
180
|
+
- test/test_distribution.rb
|
181
|
+
- test/test_creation.rb
|
182
|
+
- test/test_array.rb
|
183
|
+
- test/test_sequence.rb
|
184
|
+
- test/test_environment.rb
|
185
|
+
- test/test_functions.rb
|
186
|
+
- test/test_basic.rb
|
187
|
+
- test/test_vector.rb
|
188
|
+
- test/test_mdarray.rb
|
189
|
+
- test/test_subsetting.rb
|
190
|
+
- test/test_factor.rb
|
191
|
+
- test/test_R_interface.rb
|
192
|
+
- test/test_operators.rb
|
193
|
+
- test/test_linear_model.rb
|
194
|
+
- test/test_matrix.rb
|
195
|
+
- test/test_dataframe.rb
|
196
|
+
- test/test_list.rb
|