galaaz 0.4.0

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.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +32 -0
  3. data/Rakefile +177 -0
  4. data/bin/galaaz +8 -0
  5. data/examples/50Plots_MasterList/scatter_plot.rb +51 -0
  6. data/examples/baseball.csv +1 -0
  7. data/examples/baseball.rb +16 -0
  8. data/examples/ggplot.rb +178 -0
  9. data/examples/islr/Figure.jpg +0 -0
  10. data/examples/islr/all.rb +32 -0
  11. data/examples/islr/ch2.spec.rb +148 -0
  12. data/examples/islr/ch3.spec.rb +28 -0
  13. data/examples/islr/ch3_boston.rb +77 -0
  14. data/examples/islr/ch3_multiple_regression.rb +36 -0
  15. data/examples/islr/ch6.spec.rb +64 -0
  16. data/examples/paper/paper.rb +36 -0
  17. data/examples/sthda_ggplot/README.md +38 -0
  18. data/examples/sthda_ggplot/all.rb +68 -0
  19. data/examples/sthda_ggplot/one_variable_continuous/density_gg.rb +52 -0
  20. data/examples/sthda_ggplot/one_variable_continuous/geom_area.rb +61 -0
  21. data/examples/sthda_ggplot/one_variable_continuous/geom_density.rb +77 -0
  22. data/examples/sthda_ggplot/one_variable_continuous/geom_dotplot.rb +69 -0
  23. data/examples/sthda_ggplot/one_variable_continuous/geom_freqpoly.rb +69 -0
  24. data/examples/sthda_ggplot/one_variable_continuous/geom_histogram.rb +62 -0
  25. data/examples/sthda_ggplot/one_variable_continuous/histogram_density.rb +55 -0
  26. data/examples/sthda_ggplot/one_variable_continuous/stat.rb +62 -0
  27. data/examples/sthda_ggplot/one_variable_discrete/bar.rb +54 -0
  28. data/examples/sthda_ggplot/qplots/box_violin_dot.rb +57 -0
  29. data/examples/sthda_ggplot/qplots/scatter_plots.rb +67 -0
  30. data/examples/sthda_ggplot/scatter_gg.rb +60 -0
  31. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_bin2d.rb +49 -0
  32. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_density2d.rb +64 -0
  33. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_hex.rb +52 -0
  34. data/examples/sthda_ggplot/two_variables_cont_cont/geom_point.rb +65 -0
  35. data/examples/sthda_ggplot/two_variables_cont_cont/geom_smooth.rb +66 -0
  36. data/examples/sthda_ggplot/two_variables_cont_cont/misc.rb +83 -0
  37. data/examples/sthda_ggplot/two_variables_cont_function/geom_area.rb +63 -0
  38. data/examples/sthda_ggplot/two_variables_disc_cont/geom_bar.rb +85 -0
  39. data/examples/sthda_ggplot/two_variables_disc_cont/geom_boxplot.rb +62 -0
  40. data/examples/sthda_ggplot/two_variables_disc_cont/geom_dotplot.rb +75 -0
  41. data/examples/sthda_ggplot/two_variables_disc_cont/geom_jitter.rb +74 -0
  42. data/examples/sthda_ggplot/two_variables_disc_cont/geom_line.rb +55 -0
  43. data/examples/sthda_ggplot/two_variables_disc_cont/geom_violin.rb +70 -0
  44. data/examples/sthda_ggplot/two_variables_disc_disc/geom_jitter.rb +40 -0
  45. data/examples/sthda_ggplot/two_variables_error/geom_crossbar.rb +108 -0
  46. data/examples/subsetting.rb +372 -0
  47. data/lib/expression.rb +45 -0
  48. data/lib/galaaz.rb +27 -0
  49. data/lib/r.rb +118 -0
  50. data/lib/r_methods.rb +89 -0
  51. data/lib/rbinary_operators.rb +226 -0
  52. data/lib/rclosure.rb +34 -0
  53. data/lib/rdata_frame.rb +63 -0
  54. data/lib/renvironment.rb +34 -0
  55. data/lib/rexpression.rb +34 -0
  56. data/lib/rindexed_object.rb +68 -0
  57. data/lib/rlanguage.rb +64 -0
  58. data/lib/rlist.rb +72 -0
  59. data/lib/rmatrix.rb +38 -0
  60. data/lib/rmd_indexed_object.rb +43 -0
  61. data/lib/robject.rb +297 -0
  62. data/lib/rpkg.rb +53 -0
  63. data/lib/rsupport.rb +292 -0
  64. data/lib/rsupport_scope.rb +77 -0
  65. data/lib/rsymbol.rb +57 -0
  66. data/lib/ruby_callback.rb +83 -0
  67. data/lib/ruby_extensions.rb +74 -0
  68. data/lib/runary_operators.rb +58 -0
  69. data/lib/rvector.rb +117 -0
  70. data/r_requires/ggplot.rb +31 -0
  71. data/specs/all.rb +45 -0
  72. data/specs/r_dataframe.spec.rb +181 -0
  73. data/specs/r_eval.spec.rb +164 -0
  74. data/specs/r_function.spec.rb +105 -0
  75. data/specs/r_language.spec.rb +135 -0
  76. data/specs/r_list.spec.rb +129 -0
  77. data/specs/r_list_apply.spec.rb +99 -0
  78. data/specs/r_matrix.spec.rb +83 -0
  79. data/specs/r_vector_creation.spec.rb +99 -0
  80. data/specs/r_vector_functions.spec.rb +59 -0
  81. data/specs/r_vector_object.spec.rb +94 -0
  82. data/specs/r_vector_operators.spec.rb +174 -0
  83. data/specs/r_vector_subsetting.spec.rb +136 -0
  84. data/specs/tmp.rb +134 -0
  85. data/version.rb +2 -0
  86. metadata +198 -0
@@ -0,0 +1,134 @@
1
+ # coding: utf-8
2
+
3
+ ##########################################################################################
4
+ # @author Rodrigo Botafogo
5
+ #
6
+ # Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
7
+ # and distribute this software and its documentation, without fee and without a signed
8
+ # licensing agreement, is hereby granted, provided that the above copyright notice, this
9
+ # paragraph and the following two paragraphs appear in all copies, modifications, and
10
+ # distributions.
11
+ #
12
+ # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
13
+ # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
14
+ # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
15
+ # POSSIBILITY OF SUCH DAMAGE.
16
+ #
17
+ # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
19
+ # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
20
+ # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
21
+ # OR MODIFICATIONS.
22
+ ##########################################################################################
23
+
24
+ require 'galaaz'
25
+
26
+ class ArrayEmul
27
+ attr_reader :array
28
+
29
+ def initialize
30
+ @array = []
31
+ end
32
+
33
+ def method_missing(symbol, *args)
34
+ @array.send(symbol, *args)
35
+ end
36
+
37
+ def to_s
38
+ @array.to_s
39
+ end
40
+
41
+ def pp
42
+ puts @array.to_s
43
+ end
44
+
45
+ def fetch(index)
46
+ @array[index[0]]
47
+ end
48
+
49
+ end
50
+
51
+ make_obj = Polyglot.eval("R", <<-R)
52
+ function(ruby_obj) {
53
+ x = list(ruby_obj);
54
+ attr(x, "class") = "ruby_obj";
55
+ x;
56
+ }
57
+ R
58
+
59
+ rf = Polyglot.eval("R", <<-R)
60
+ function(ruby_obj) {
61
+ # print(ruby_obj);
62
+ attr(ruby_obj, "class") = "ruby_obj"
63
+ print(ruby_obj@to_s());
64
+ print(class(ruby_obj));
65
+ # df = data.frame(ruby_obj);
66
+ }
67
+
68
+ print.ruby_obj = function(x, index, ...) {
69
+ print(index);
70
+ x[[1]]@fetch(index);
71
+ }
72
+
73
+ R
74
+
75
+ h = ArrayEmul.new
76
+ h << 1 << 2 << 3
77
+ puts h
78
+
79
+ r_obj = make_obj.call(h)
80
+ p Polyglot.eval("R", "print").call(r_obj, 0)[0]
81
+
82
+
83
+
84
+
85
+ =begin
86
+ sym = +:sym
87
+ # construct a formula without the lhs: ~sym1 + sym2
88
+ puts +:sym1 + +:sym2
89
+ f1 = +:sym1 + :sym2
90
+ puts +:sym1 + +:sym2 - +:sym3
91
+ puts +:sym1 * +:sym2
92
+ =end
93
+
94
+ #puts :sym3 ** 2
95
+ # p (:sym1 + :sym2 * :sym3 ** 2).expression
96
+ #puts E.log(:y + 1).to_s
97
+
98
+ # puts :sym1 ** 2
99
+ # puts +:sym1 + (:sym1 ** 2).i
100
+
101
+ # puts +:y =~ +:sym1 + +:sym2 * +:sym3 + (:sym1 ** 2).i
102
+ # puts +:y =~ :all
103
+
104
+
105
+ # p sym
106
+ # puts sym
107
+ # sym.typeof
108
+ =begin
109
+ f1 = +:sym1 + +:sym2
110
+ puts f1
111
+ puts f1.deparse
112
+
113
+ puts R.c(1, 2, 3).deparse
114
+ puts R.list(a: 1, b: 2, c: 3).deparse
115
+ =end
116
+
117
+ =begin
118
+ # Set seed
119
+ R.set__seed(123)
120
+
121
+ # Data
122
+ x = R.rnorm(5)
123
+ x2 = R.rnorm(5)
124
+ y = R.rnorm(5)
125
+
126
+ # Model frame
127
+ puts R.model__frame(+:y =~ +:x * +:x2, data: R.data__frame(x: x, y: y, x2: x2))
128
+
129
+ puts R.model__frame(+:y =~ +:x + +:x2 + (+:x ^ +:x2),
130
+ data: R.data__frame(x: x, y: y, x2: x2))
131
+
132
+ puts R.model__frame(+:y =~ +:x + (:x ** 2).i,
133
+ data: R.data__frame(x: R.rnorm(5), y: R.rnorm(5)))
134
+ =end
@@ -0,0 +1,2 @@
1
+ $gem_name = "galaaz"
2
+ $version="0.4.0"
metadata ADDED
@@ -0,0 +1,198 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: galaaz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: ruby
6
+ authors:
7
+ - Rodrigo Botafogo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ prerelease: false
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '3.8'
21
+ type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simplecov
29
+ prerelease: false
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0.16'
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ prerelease: false
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '5.0'
49
+ type: :development
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ prerelease: false
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '12.0'
63
+ type: :development
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '12.0'
69
+ description: "Galaaz brings the power of R to the Ruby community. Galaaz \nis based
70
+ on TruffleRuby and FastR, GraalVM-based interpreters for Ruby and the R language
71
+ \nfor statistical computing respectively.\n\nOver the past two decades, the R language
72
+ for statistical computing has emerged as the de \nfacto standard for analysts, statisticians,
73
+ and scientists. Today, a wide range of \nenterprises – from pharmaceuticals to insurance
74
+ – depend on R for key business uses. FastR \nis a new implementation of the R language
75
+ and environment for the Graal Virtual Machine.\n\nGalaaz tightly couples Ruby and
76
+ R and allows the use of R inside a Ruby script. In a sense, \nGalaaz is similar
77
+ to other solutions such as RinRuby, Rpy2, PipeR, and reticulate \n(https://blog.rstudio.com/2018/03/26/reticulate-r-interface-to-python/).
78
+ However, since \nGalaaz couples TruffleRuby and FastR that both target the JVM there
79
+ is no need to integrate \nboth solutions and there is no need to send data between
80
+ Ruby and R, as it all resides in \nthe same VM. \n\nFurther, installation of Galaaz
81
+ does not require the installation of GNU R. When installing\nGraalVM, just install
82
+ TruffleRuby and FastR.\n"
83
+ email: rodrigo.a.botafogo@gmail.com
84
+ executables:
85
+ - galaaz
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - README.md
90
+ - Rakefile
91
+ - bin/galaaz
92
+ - examples/50Plots_MasterList/scatter_plot.rb
93
+ - examples/baseball.csv
94
+ - examples/baseball.rb
95
+ - examples/ggplot.rb
96
+ - examples/islr/Figure.jpg
97
+ - examples/islr/all.rb
98
+ - examples/islr/ch2.spec.rb
99
+ - examples/islr/ch3.spec.rb
100
+ - examples/islr/ch3_boston.rb
101
+ - examples/islr/ch3_multiple_regression.rb
102
+ - examples/islr/ch6.spec.rb
103
+ - examples/paper/paper.rb
104
+ - examples/sthda_ggplot/README.md
105
+ - examples/sthda_ggplot/all.rb
106
+ - examples/sthda_ggplot/one_variable_continuous/density_gg.rb
107
+ - examples/sthda_ggplot/one_variable_continuous/geom_area.rb
108
+ - examples/sthda_ggplot/one_variable_continuous/geom_density.rb
109
+ - examples/sthda_ggplot/one_variable_continuous/geom_dotplot.rb
110
+ - examples/sthda_ggplot/one_variable_continuous/geom_freqpoly.rb
111
+ - examples/sthda_ggplot/one_variable_continuous/geom_histogram.rb
112
+ - examples/sthda_ggplot/one_variable_continuous/histogram_density.rb
113
+ - examples/sthda_ggplot/one_variable_continuous/stat.rb
114
+ - examples/sthda_ggplot/one_variable_discrete/bar.rb
115
+ - examples/sthda_ggplot/qplots/box_violin_dot.rb
116
+ - examples/sthda_ggplot/qplots/scatter_plots.rb
117
+ - examples/sthda_ggplot/scatter_gg.rb
118
+ - examples/sthda_ggplot/two_variables_cont_bivariate/geom_bin2d.rb
119
+ - examples/sthda_ggplot/two_variables_cont_bivariate/geom_density2d.rb
120
+ - examples/sthda_ggplot/two_variables_cont_bivariate/geom_hex.rb
121
+ - examples/sthda_ggplot/two_variables_cont_cont/geom_point.rb
122
+ - examples/sthda_ggplot/two_variables_cont_cont/geom_smooth.rb
123
+ - examples/sthda_ggplot/two_variables_cont_cont/misc.rb
124
+ - examples/sthda_ggplot/two_variables_cont_function/geom_area.rb
125
+ - examples/sthda_ggplot/two_variables_disc_cont/geom_bar.rb
126
+ - examples/sthda_ggplot/two_variables_disc_cont/geom_boxplot.rb
127
+ - examples/sthda_ggplot/two_variables_disc_cont/geom_dotplot.rb
128
+ - examples/sthda_ggplot/two_variables_disc_cont/geom_jitter.rb
129
+ - examples/sthda_ggplot/two_variables_disc_cont/geom_line.rb
130
+ - examples/sthda_ggplot/two_variables_disc_cont/geom_violin.rb
131
+ - examples/sthda_ggplot/two_variables_disc_disc/geom_jitter.rb
132
+ - examples/sthda_ggplot/two_variables_error/geom_crossbar.rb
133
+ - examples/subsetting.rb
134
+ - lib/expression.rb
135
+ - lib/galaaz.rb
136
+ - lib/r.rb
137
+ - lib/r_methods.rb
138
+ - lib/rbinary_operators.rb
139
+ - lib/rclosure.rb
140
+ - lib/rdata_frame.rb
141
+ - lib/renvironment.rb
142
+ - lib/rexpression.rb
143
+ - lib/rindexed_object.rb
144
+ - lib/rlanguage.rb
145
+ - lib/rlist.rb
146
+ - lib/rmatrix.rb
147
+ - lib/rmd_indexed_object.rb
148
+ - lib/robject.rb
149
+ - lib/rpkg.rb
150
+ - lib/rsupport.rb
151
+ - lib/rsupport_scope.rb
152
+ - lib/rsymbol.rb
153
+ - lib/ruby_callback.rb
154
+ - lib/ruby_extensions.rb
155
+ - lib/runary_operators.rb
156
+ - lib/rvector.rb
157
+ - r_requires/ggplot.rb
158
+ - specs/all.rb
159
+ - specs/r_dataframe.spec.rb
160
+ - specs/r_eval.spec.rb
161
+ - specs/r_function.spec.rb
162
+ - specs/r_language.spec.rb
163
+ - specs/r_list.spec.rb
164
+ - specs/r_list_apply.spec.rb
165
+ - specs/r_matrix.spec.rb
166
+ - specs/r_vector_creation.spec.rb
167
+ - specs/r_vector_functions.spec.rb
168
+ - specs/r_vector_object.spec.rb
169
+ - specs/r_vector_operators.spec.rb
170
+ - specs/r_vector_subsetting.spec.rb
171
+ - specs/tmp.rb
172
+ - version.rb
173
+ homepage: http://github.com/rbotafogo/galaaz/wiki
174
+ licenses:
175
+ - BSD-2-Clause
176
+ metadata:
177
+ yard.run: yri
178
+ post_install_message:
179
+ rdoc_options: []
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ requirements: []
193
+ rubyforge_project:
194
+ rubygems_version: 2.6.14.1
195
+ signing_key:
196
+ specification_version: 4
197
+ summary: Tightly coupling Ruby and R
198
+ test_files: []