galaaz 0.4.10 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2048 -531
- data/Rakefile +3 -2
- data/bin/gknit +152 -6
- data/bin/gknit-draft +105 -0
- data/bin/gknit-draft.rb +28 -0
- data/bin/gknit_Rscript +127 -0
- data/bin/grun +27 -1
- data/bin/gstudio +47 -4
- data/bin/{gstudio.rb → gstudio_irb.rb} +0 -0
- data/bin/gstudio_pry.rb +7 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.html +10 -195
- data/blogs/galaaz_ggplot/galaaz_ggplot.md +404 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/midwest_rb.png +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/scatter_plot_rb.png +0 -0
- data/blogs/gknit/gknit.Rmd +5 -3
- data/blogs/gknit/gknit.pdf +0 -0
- data/blogs/gknit/lst.rds +0 -0
- data/blogs/manual/lst.rds +0 -0
- data/blogs/manual/manual.Rmd +826 -53
- data/blogs/manual/manual.html +2338 -695
- data/blogs/manual/manual.md +2032 -539
- data/blogs/manual/manual.pdf +0 -0
- data/blogs/manual/manual.tex +1804 -594
- data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
- data/blogs/manual/manual_files/figure-html/diverging_bar.png +0 -0
- data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
- data/blogs/manual/manual_files/figure-latex/diverging_bar.pdf +0 -0
- data/blogs/manual/model.rb +41 -0
- data/blogs/nse_dplyr/nse_dplyr.Rmd +226 -73
- data/blogs/nse_dplyr/nse_dplyr.html +254 -336
- data/blogs/nse_dplyr/nse_dplyr.md +353 -158
- data/blogs/oh_my/oh_my.html +274 -386
- data/blogs/oh_my/oh_my.md +208 -205
- data/blogs/ruby_plot/ruby_plot.html +20 -205
- data/blogs/ruby_plot/ruby_plot.md +14 -15
- data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png +0 -0
- data/examples/Bibliography/master.bib +50 -0
- data/examples/Bibliography/stats.bib +72 -0
- data/examples/islr/x_y_rnorm.jpg +0 -0
- data/examples/latex_templates/Test-acm_article/Makefile +16 -0
- data/examples/latex_templates/Test-acm_article/Test-acm_article.Rmd +65 -0
- data/examples/latex_templates/Test-acm_article/acm_proc_article-sp.cls +1670 -0
- data/examples/latex_templates/Test-acm_article/sensys-abstract.cls +703 -0
- data/examples/latex_templates/Test-acm_article/sigproc.bib +59 -0
- data/examples/latex_templates/Test-acs_article/Test-acs_article.Rmd +260 -0
- data/examples/latex_templates/Test-acs_article/Test-acs_article.pdf +0 -0
- data/examples/latex_templates/Test-acs_article/acs-Test-acs_article.bib +11 -0
- data/examples/latex_templates/Test-acs_article/acs-my_output.bib +11 -0
- data/examples/latex_templates/Test-acs_article/acstest.bib +17 -0
- data/examples/latex_templates/Test-aea_article/AEA.cls +1414 -0
- data/{blogs/gknit/marshal.dump → examples/latex_templates/Test-aea_article/BibFile.bib} +0 -0
- data/examples/latex_templates/Test-aea_article/Test-aea_article.Rmd +108 -0
- data/examples/latex_templates/Test-aea_article/Test-aea_article.pdf +0 -0
- data/examples/latex_templates/Test-aea_article/aea.bst +1269 -0
- data/examples/latex_templates/Test-aea_article/multicol.sty +853 -0
- data/examples/latex_templates/Test-aea_article/references.bib +0 -0
- data/examples/latex_templates/Test-aea_article/setspace.sty +546 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.Rmd +256 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.pdf +0 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.pdfsync +3397 -0
- data/examples/latex_templates/Test-amq_article/pics/Figure2.pdf +0 -0
- data/examples/latex_templates/Test-ams_article/Test-ams_article.Rmd +215 -0
- data/examples/latex_templates/Test-ams_article/amstest.bib +436 -0
- data/examples/latex_templates/Test-asa_article/Test-asa_article.Rmd +153 -0
- data/examples/latex_templates/Test-asa_article/Test-asa_article.pdf +0 -0
- data/examples/latex_templates/Test-asa_article/agsm.bst +1353 -0
- data/examples/latex_templates/Test-asa_article/bibliography.bib +233 -0
- data/examples/latex_templates/Test-ieee_article/IEEEtran.bst +2409 -0
- data/examples/latex_templates/Test-ieee_article/IEEEtran.cls +6346 -0
- data/examples/latex_templates/Test-ieee_article/Test-ieee_article.Rmd +175 -0
- data/examples/latex_templates/Test-ieee_article/Test-ieee_article.pdf +0 -0
- data/examples/latex_templates/Test-ieee_article/mybibfile.bib +20 -0
- data/examples/latex_templates/Test-rjournal_article/RJournal.sty +335 -0
- data/examples/latex_templates/Test-rjournal_article/RJreferences.bib +18 -0
- data/examples/latex_templates/Test-rjournal_article/RJwrapper.pdf +0 -0
- data/examples/latex_templates/Test-rjournal_article/Test-rjournal_article.Rmd +52 -0
- data/examples/latex_templates/Test-springer_article/Test-springer_article.Rmd +65 -0
- data/examples/latex_templates/Test-springer_article/Test-springer_article.pdf +0 -0
- data/examples/latex_templates/Test-springer_article/bibliography.bib +26 -0
- data/examples/latex_templates/Test-springer_article/spbasic.bst +1658 -0
- data/examples/latex_templates/Test-springer_article/spmpsci.bst +1512 -0
- data/examples/latex_templates/Test-springer_article/spphys.bst +1443 -0
- data/examples/latex_templates/Test-springer_article/svglov3.clo +113 -0
- data/examples/latex_templates/Test-springer_article/svjour3.cls +1431 -0
- data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.Rmd +73 -0
- data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.Rmd +382 -0
- data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.Rmd +164 -0
- data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.Rmd +92 -0
- data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/attend-grade-relationships.csv +482 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.Rmd +280 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.pdf +0 -0
- data/examples/rmarkdown/svm-xaringan-example/svm-xaringan-example.Rmd +386 -0
- data/lib/R_interface/r.rb +1 -1
- data/lib/R_interface/r_libs.R +1 -1
- data/lib/R_interface/r_methods.rb +10 -0
- data/lib/R_interface/rpkg.rb +1 -0
- data/lib/R_interface/rsupport.rb +4 -6
- data/lib/gknit.rb +2 -0
- data/lib/gknit/draft.rb +105 -0
- data/lib/gknit/knitr_engine.rb +0 -33
- data/lib/util/exec_ruby.rb +1 -27
- data/specs/figures/bg.jpeg +0 -0
- data/specs/figures/bg.png +0 -0
- data/specs/figures/dose_len.png +0 -0
- data/specs/figures/no_args.jpeg +0 -0
- data/specs/figures/no_args.png +0 -0
- data/specs/figures/width_height.jpeg +0 -0
- data/specs/figures/width_height.png +0 -0
- data/specs/figures/width_height_units1.jpeg +0 -0
- data/specs/figures/width_height_units1.png +0 -0
- data/specs/figures/width_height_units2.jpeg +0 -0
- data/specs/figures/width_height_units2.png +0 -0
- data/specs/r_dataframe.spec.rb +11 -11
- data/specs/ruby_expression.spec.rb +1 -0
- data/specs/tmp.rb +41 -20
- data/version.rb +1 -1
- metadata +73 -35
- data/blogs/galaaz_ggplot/galaaz_ggplot.aux +0 -41
- data/blogs/galaaz_ggplot/galaaz_ggplot.out +0 -10
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/midwest_rb.pdf +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/scatter_plot_rb.pdf +0 -0
- data/blogs/gknit/gknit.md +0 -1430
- data/blogs/gknit/gknit.tex +0 -1358
- data/blogs/manual/graph.rb +0 -29
- data/blogs/nse_dplyr/nse_dplyr.tex +0 -1373
- data/blogs/ruby_plot/ruby_plot.Rmd_external_figs +0 -662
- data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg +0 -57
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg +0 -106
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg +0 -110
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg +0 -174
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg +0 -236
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.svg +0 -296
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg +0 -236
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg +0 -218
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg +0 -128
- data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg +0 -150
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/dose_len.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
- data/examples/paper/paper.rb +0 -36
data/blogs/oh_my/oh_my.md
CHANGED
@@ -75,11 +75,11 @@ keyword 'attr_reader' and a colom before the variables name:
|
|
75
75
|
|
76
76
|
|
77
77
|
|
78
|
-
```
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
```ruby
|
79
|
+
class Trajectories
|
80
|
+
attr_reader :times
|
81
|
+
attr_reader :matrix
|
82
|
+
end
|
83
83
|
```
|
84
84
|
|
85
85
|
|
@@ -87,27 +87,27 @@ In order to create a new instance of object Trajectories we call method new on t
|
|
87
87
|
we can store the result in a varible (not an instance variable) as bellow:
|
88
88
|
|
89
89
|
|
90
|
-
```
|
91
|
-
|
90
|
+
```ruby
|
91
|
+
@traj = Trajectories.new
|
92
92
|
```
|
93
93
|
|
94
94
|
We now have in variable '@traj' a Trajectories object. In Ruby, printing variable 'traj' will
|
95
95
|
only print the class name of the object and not it contents as in R.
|
96
96
|
|
97
97
|
|
98
|
-
```
|
99
|
-
|
98
|
+
```ruby
|
99
|
+
puts @traj
|
100
100
|
```
|
101
101
|
|
102
102
|
```
|
103
|
-
## #<
|
103
|
+
## #<RC::Trajectories:0x2d8>
|
104
104
|
```
|
105
105
|
|
106
106
|
To see the contents of an object, one needs to access its components using the '.' operator:
|
107
107
|
|
108
108
|
|
109
|
-
```
|
110
|
-
|
109
|
+
```ruby
|
110
|
+
puts @traj.times
|
111
111
|
```
|
112
112
|
|
113
113
|
# Constructor
|
@@ -120,24 +120,24 @@ a 'times' value and a 'matrix' value and they are used to initialize the value o
|
|
120
120
|
instance variables:
|
121
121
|
|
122
122
|
|
123
|
-
```
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
123
|
+
```ruby
|
124
|
+
class Trajectories
|
125
|
+
|
126
|
+
attr_reader :times
|
127
|
+
attr_reader :matrix
|
128
|
+
|
129
|
+
#----------------------------------------------------------
|
130
|
+
# Initializes the Trajectories class. Takes two parameters
|
131
|
+
# @param times
|
132
|
+
# @param matrix
|
133
|
+
#----------------------------------------------------------
|
134
|
+
|
135
|
+
def initialize(times: nil, matrix: nil)
|
136
|
+
@times = times
|
137
|
+
@matrix = matrix
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
141
|
```
|
142
142
|
|
143
143
|
Up to this point, everything described is pure Ruby code and has absolutely no relationship
|
@@ -154,12 +154,12 @@ When passing arguments to an R function in R one uses the '=' sign after the slo
|
|
154
154
|
one uses the ':' operator after parameter's name as we can see bellow:
|
155
155
|
|
156
156
|
|
157
|
-
```
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
157
|
+
```ruby
|
158
|
+
# Create a Trajectories passing a times vector, but no matrix parameter
|
159
|
+
@traj = Trajectories.new(times: R.c(1, 2, 3, 4))
|
160
|
+
|
161
|
+
# Create a Trajectories with times and matrix
|
162
|
+
@traj2 = Trajectories.new(times: R.c(1, 3), matrix: R.matrix((1..4), ncol: 2))
|
163
163
|
```
|
164
164
|
|
165
165
|
# Access to Instance Variables (to reach a slot)
|
@@ -173,8 +173,8 @@ that everything is fine:
|
|
173
173
|
|
174
174
|
|
175
175
|
|
176
|
-
```
|
177
|
-
|
176
|
+
```ruby
|
177
|
+
puts @traj.times
|
178
178
|
```
|
179
179
|
|
180
180
|
```
|
@@ -185,10 +185,10 @@ We now have the expected value. Note that the 'times' vector is printed exactly
|
|
185
185
|
if we were using GNU R. Let's now take a look at variable 'traj2':
|
186
186
|
|
187
187
|
|
188
|
-
```
|
189
|
-
|
190
|
-
|
191
|
-
|
188
|
+
```ruby
|
189
|
+
puts @traj2.times
|
190
|
+
puts
|
191
|
+
puts @traj2.matrix
|
192
192
|
```
|
193
193
|
|
194
194
|
```
|
@@ -228,34 +228,34 @@ Cochin and Saint-Anne. We first show the code in R and the corresponding Galaaz
|
|
228
228
|
This same code in Galaaz becomes:
|
229
229
|
|
230
230
|
|
231
|
-
```
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
231
|
+
```ruby
|
232
|
+
@trajPitie = Trajectories.new
|
233
|
+
|
234
|
+
@trajCochin = Trajectories.new(times: R.c(1,3,4,5),
|
235
|
+
matrix: R.rbind(
|
236
|
+
R.c(15,15.1, 15.2, 15.2),
|
237
|
+
R.c(16,15.9, 16,16.4),
|
238
|
+
R.c(15.2, R::NA, 15.3, 15.3),
|
239
|
+
R.c(15.7, 15.6, 15.8, 16)))
|
240
|
+
|
241
|
+
@trajStAnne =
|
242
|
+
Trajectories.new(times: R.c((1..10), R.c(6..16) * 2),
|
243
|
+
matrix: (R.rbind(
|
244
|
+
R.matrix(R.seq(16, 19, length: 21), ncol: 21,
|
245
|
+
nrow: 50, byrow: true),
|
246
|
+
R.matrix(R.seq(15.8, 18, length: 21), ncol: 21,
|
247
|
+
nrow: 30, byrow: true)) + R.rnorm(21*80, 0, 0.2)))
|
248
248
|
```
|
249
249
|
|
250
250
|
Let's check that the 'times' and 'matrix' instance variables were correctly set:
|
251
251
|
|
252
252
|
|
253
|
-
```
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
253
|
+
```ruby
|
254
|
+
puts @trajCochin.times
|
255
|
+
puts
|
256
|
+
puts @trajCochin.matrix
|
257
|
+
puts
|
258
|
+
puts @trajStAnne.times
|
259
259
|
```
|
260
260
|
|
261
261
|
```
|
@@ -284,35 +284,35 @@ In the example bellow, a class TrajectoriesBis is created with default value 1 f
|
|
284
284
|
matrix with no elements in matrix.
|
285
285
|
|
286
286
|
|
287
|
-
```
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
287
|
+
```ruby
|
288
|
+
class TrajectoriesBis
|
289
|
+
|
290
|
+
attr_reader :times
|
291
|
+
attr_reader :matrix
|
292
|
+
|
293
|
+
#----------------------------------------------------------
|
294
|
+
# Initializes the Trajectories class. Takes two parameters
|
295
|
+
# @param times
|
296
|
+
# @param matrix
|
297
|
+
#----------------------------------------------------------
|
298
|
+
|
299
|
+
def initialize(times: 1, matrix: R.matrix(0))
|
300
|
+
@times = times
|
301
|
+
@matrix = matrix
|
302
|
+
end
|
303
|
+
|
304
|
+
end
|
305
|
+
|
306
|
+
@traj_bis = TrajectoriesBis.new
|
307
307
|
```
|
308
308
|
|
309
309
|
Let's take a look at our new class:
|
310
310
|
|
311
311
|
|
312
|
-
```
|
313
|
-
|
314
|
-
|
315
|
-
|
312
|
+
```ruby
|
313
|
+
puts @traj_bis.times
|
314
|
+
puts
|
315
|
+
puts @traj_bis.matrix
|
316
316
|
```
|
317
317
|
|
318
318
|
```
|
@@ -326,34 +326,34 @@ Note that '@traj_bis.times' is the numeric 1, and what we actually want is a vec
|
|
326
326
|
with [1] in it.
|
327
327
|
|
328
328
|
|
329
|
-
```
|
330
|
-
|
331
|
-
##
|
332
|
-
## attr_reader :times
|
333
|
-
## attr_reader :matrix
|
334
|
-
##
|
335
|
-
## #----------------------------------------------------------
|
336
|
-
## # Initializes the Trajectories class. Takes two parameters
|
337
|
-
## # @param times [R::Vector] should be an R vector.
|
338
|
-
## # @param matrix [R::Matrix] should be an R matrix.
|
339
|
-
## #----------------------------------------------------------
|
340
|
-
##
|
341
|
-
## # Use R.c to convert number 1 to a vector
|
342
|
-
## def initialize(times: R.c(1), matrix: R.matrix(0))
|
343
|
-
## @times = times
|
344
|
-
## @matrix = matrix
|
345
|
-
## end
|
346
|
-
##
|
347
|
-
## end
|
348
|
-
##
|
349
|
-
## @traj_bis = TrajectoriesBis.new
|
350
|
-
```
|
329
|
+
```ruby
|
330
|
+
class TrajectoriesBis
|
351
331
|
|
332
|
+
attr_reader :times
|
333
|
+
attr_reader :matrix
|
352
334
|
|
335
|
+
#----------------------------------------------------------
|
336
|
+
# Initializes the Trajectories class. Takes two parameters
|
337
|
+
# @param times [R::Vector] should be an R vector.
|
338
|
+
# @param matrix [R::Matrix] should be an R matrix.
|
339
|
+
#----------------------------------------------------------
|
340
|
+
|
341
|
+
# Use R.c to convert number 1 to a vector
|
342
|
+
def initialize(times: R.c(1), matrix: R.matrix(0))
|
343
|
+
@times = times
|
344
|
+
@matrix = matrix
|
345
|
+
end
|
346
|
+
|
347
|
+
end
|
348
|
+
|
349
|
+
@traj_bis = TrajectoriesBis.new
|
353
350
|
```
|
354
|
-
|
355
|
-
|
356
|
-
|
351
|
+
|
352
|
+
|
353
|
+
```ruby
|
354
|
+
puts @traj_bis.times
|
355
|
+
puts
|
356
|
+
puts @traj_bis.matrix
|
357
357
|
```
|
358
358
|
|
359
359
|
```
|
@@ -417,43 +417,43 @@ Ruby's print is defined inside the Kernel class, so, in order to call Ruby's pri
|
|
417
417
|
definition of Trajectories's print we need to write 'Kernel.print'.
|
418
418
|
|
419
419
|
|
420
|
-
```
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
##
|
433
|
-
## def initialize(times: nil, matrix: nil)
|
434
|
-
## @times = times
|
435
|
-
## @matrix = matrix
|
436
|
-
## end
|
437
|
-
##
|
438
|
-
## #----------------------------------------------------------
|
439
|
-
## #
|
440
|
-
## #----------------------------------------------------------
|
441
|
-
##
|
442
|
-
## def print
|
443
|
-
## puts("*** Class Trajectories, method Print *** ")
|
444
|
-
## Kernel.print("times = ")
|
445
|
-
## puts @times
|
446
|
-
## puts("traj =")
|
447
|
-
## puts @matrix
|
448
|
-
## puts("******* End Print (trajectories) ******* ")
|
449
|
-
## end
|
450
|
-
##
|
451
|
-
## end
|
452
|
-
```
|
420
|
+
```ruby
|
421
|
+
class Trajectories
|
422
|
+
|
423
|
+
attr_reader :times
|
424
|
+
attr_reader :matrix
|
425
|
+
|
426
|
+
|
427
|
+
#----------------------------------------------------------
|
428
|
+
# Initializes the Trajectories class. Takes two parameters
|
429
|
+
# @param times [R::Vector] should be an R vector.
|
430
|
+
# @param matrix [R::Matrix] should be an R matrix.
|
431
|
+
#----------------------------------------------------------
|
453
432
|
|
433
|
+
def initialize(times: nil, matrix: nil)
|
434
|
+
@times = times
|
435
|
+
@matrix = matrix
|
436
|
+
end
|
454
437
|
|
438
|
+
#----------------------------------------------------------
|
439
|
+
#
|
440
|
+
#----------------------------------------------------------
|
441
|
+
|
442
|
+
def print
|
443
|
+
puts("*** Class Trajectories, method Print *** ")
|
444
|
+
Kernel.print("times = ")
|
445
|
+
puts @times
|
446
|
+
puts("traj =")
|
447
|
+
puts @matrix
|
448
|
+
puts("******* End Print (trajectories) ******* ")
|
449
|
+
end
|
450
|
+
|
451
|
+
end
|
455
452
|
```
|
456
|
-
|
453
|
+
|
454
|
+
|
455
|
+
```ruby
|
456
|
+
@trajCochin.print
|
457
457
|
```
|
458
458
|
|
459
459
|
```
|
@@ -523,75 +523,78 @@ features of Galaaz, some we have already seen, others will be described now:
|
|
523
523
|
|
524
524
|
|
525
525
|
|
526
|
+
```ruby
|
527
|
+
class Trajectories
|
528
|
+
|
529
|
+
#----------------------------------------------------------
|
530
|
+
#
|
531
|
+
#----------------------------------------------------------
|
532
|
+
|
533
|
+
def show
|
534
|
+
puts("*** Class Trajectories, method Show *** ")
|
535
|
+
Kernel.print("times = ")
|
536
|
+
puts @times
|
537
|
+
nrow_show = [10, @matrix.nrow << 0].min
|
538
|
+
ncol_show = R.min(10, @matrix.ncol) << 0
|
539
|
+
puts("* Traj (limited to a matrix 10x10) = ")
|
540
|
+
puts @matrix[(1..nrow_show), (1..ncol_show)].format(digits: 2, nsmall: 2)
|
541
|
+
puts("******* End Show (trajectories) ******* ")
|
542
|
+
end
|
543
|
+
|
544
|
+
end
|
526
545
|
```
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
##
|
535
|
-
##
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
##
|
540
|
-
##
|
541
|
-
##
|
542
|
-
##
|
543
|
-
##
|
544
|
-
##
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
##
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
##
|
554
|
-
##
|
555
|
-
##
|
556
|
-
##
|
557
|
-
##
|
558
|
-
##
|
559
|
-
##
|
560
|
-
##
|
561
|
-
##
|
562
|
-
## [6,] "15.89" "16.03" "16.43" "16.09" "16.70" "16.80" "17.06" "16.95"
|
563
|
-
## [7,] "15.83" "16.03" "16.43" "16.79" "16.27" "16.79" "16.68" "16.98"
|
564
|
-
## [8,] "15.90" "16.38" "16.27" "16.59" "16.41" "16.17" "16.91" "17.22"
|
565
|
-
## [9,] "15.90" "15.83" "16.50" "16.24" "16.46" "16.52" "16.65" "16.94"
|
566
|
-
## [10,] "15.99" "15.94" "16.70" "16.41" "16.51" "16.62" "16.98" "16.67"
|
567
|
-
## [,9] [,10]
|
568
|
-
## [1,] "17.17" "16.92"
|
569
|
-
## [2,] "17.23" "17.46"
|
570
|
-
## [3,] "17.13" "17.17"
|
571
|
-
## [4,] "17.31" "17.39"
|
572
|
-
## [5,] "17.17" "17.63"
|
573
|
-
## [6,] "17.31" "17.05"
|
574
|
-
## [7,] "17.11" "17.54"
|
575
|
-
## [8,] "17.55" "17.58"
|
576
|
-
## [9,] "16.86" "16.85"
|
577
|
-
## [10,] "17.65" "17.45"
|
578
|
-
## ******* End Show (trajectories) *******
|
546
|
+
|
547
|
+
|
548
|
+
```ruby
|
549
|
+
@trajStAnne.show
|
550
|
+
```
|
551
|
+
|
552
|
+
```
|
553
|
+
## Message:
|
554
|
+
## Method << not found in R environment
|
555
|
+
```
|
556
|
+
|
557
|
+
```
|
558
|
+
## Message:
|
559
|
+
## /home/rbotafogo/desenv/galaaz/lib/R_interface/rsupport.rb:90:in `eval'
|
560
|
+
## /home/rbotafogo/desenv/galaaz/lib/R_interface/rsupport.rb:268:in `exec_function_name'
|
561
|
+
## /home/rbotafogo/desenv/galaaz/lib/R_interface/robject.rb:170:in `method_missing'
|
562
|
+
## /home/rbotafogo/desenv/galaaz/lib/util/exec_ruby.rb:113:in `show'
|
563
|
+
## /home/rbotafogo/desenv/galaaz/lib/util/exec_ruby.rb:103:in `get_binding'
|
564
|
+
## /home/rbotafogo/desenv/galaaz/lib/util/exec_ruby.rb:102:in `eval'
|
565
|
+
## /home/rbotafogo/desenv/galaaz/lib/util/exec_ruby.rb:102:in `exec_ruby'
|
566
|
+
## /home/rbotafogo/desenv/galaaz/lib/gknit/knitr_engine.rb:650:in `block in initialize'
|
567
|
+
## /home/rbotafogo/desenv/galaaz/lib/R_interface/ruby_callback.rb:77:in `call'
|
568
|
+
## /home/rbotafogo/desenv/galaaz/lib/R_interface/ruby_callback.rb:77:in `callback'
|
569
|
+
## (eval):3:in `function(...) {\n rb_method(...)'
|
570
|
+
## unknown.r:1:in `in_dir'
|
571
|
+
## unknown.r:1:in `block_exec'
|
572
|
+
## /home/rbotafogo/R/x86_64-pc-linux-gnu-library/fastr-20.1.0-3.6/knitr/R/block.R:92:in `call_block'
|
573
|
+
## /home/rbotafogo/R/x86_64-pc-linux-gnu-library/fastr-20.1.0-3.6/knitr/R/block.R:6:in `process_group.block'
|
574
|
+
## /home/rbotafogo/R/x86_64-pc-linux-gnu-library/fastr-20.1.0-3.6/knitr/R/block.R:3:in `<no source>'
|
575
|
+
## unknown.r:1:in `withCallingHandlers'
|
576
|
+
## unknown.r:1:in `process_file'
|
577
|
+
## unknown.r:1:in `<no source>'
|
578
|
+
## unknown.r:1:in `<no source>'
|
579
|
+
## <REPL>:4:in `<repl wrapper>'
|
580
|
+
## <REPL>:1
|
579
581
|
```
|
580
582
|
|
581
583
|
Our show method has the same problem as SS4, i.e., if an empty trajectories object is created and
|
582
584
|
we try to 'show' it, it will generate an error. Let's see it:
|
583
585
|
|
584
586
|
|
585
|
-
```
|
586
|
-
|
587
|
+
```ruby
|
588
|
+
@empty_traj = Trajectories.new
|
587
589
|
```
|
588
590
|
|
589
591
|
|
590
|
-
```
|
591
|
-
|
592
|
+
```ruby
|
593
|
+
@empty_traj.show
|
592
594
|
```
|
593
595
|
|
594
596
|
```
|
595
|
-
##
|
597
|
+
## Message:
|
598
|
+
## undefined method `nrow' for nil:NilClass
|
596
599
|
```
|
597
600
|
|