galaaz 0.4.6 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +3575 -118
  3. data/Rakefile +21 -4
  4. data/bin/gknit +152 -6
  5. data/bin/gknit-draft +105 -0
  6. data/bin/gknit-draft.rb +28 -0
  7. data/bin/gknit_Rscript +127 -0
  8. data/bin/grun +27 -1
  9. data/bin/gstudio +47 -4
  10. data/bin/{gstudio.rb → gstudio_irb.rb} +0 -0
  11. data/bin/gstudio_pry.rb +7 -0
  12. data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +3 -12
  13. data/blogs/galaaz_ggplot/galaaz_ggplot.html +77 -222
  14. data/blogs/galaaz_ggplot/galaaz_ggplot.md +4 -31
  15. data/blogs/galaaz_ggplot/galaaz_ggplot.pdf +0 -0
  16. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/midwest_rb.png +0 -0
  17. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/scatter_plot_rb.png +0 -0
  18. data/blogs/galaaz_ggplot/midwest.Rmd +1 -9
  19. data/blogs/gknit/gknit.Rmd +232 -123
  20. data/blogs/{dev/dev.html → gknit/gknit.html} +1897 -33
  21. data/blogs/gknit/gknit.pdf +0 -0
  22. data/blogs/gknit/lst.rds +0 -0
  23. data/blogs/gknit/stats.bib +27 -0
  24. data/blogs/manual/lst.rds +0 -0
  25. data/blogs/manual/manual.Rmd +1893 -47
  26. data/blogs/manual/manual.html +3153 -347
  27. data/blogs/manual/manual.md +3575 -118
  28. data/blogs/manual/manual.pdf +0 -0
  29. data/blogs/manual/manual.tex +4026 -0
  30. data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
  31. data/blogs/manual/manual_files/figure-html/diverging_bar.png +0 -0
  32. data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
  33. data/blogs/manual/manual_files/figure-latex/diverging_bar.pdf +0 -0
  34. data/blogs/{dev → manual}/model.rb +0 -0
  35. data/blogs/nse_dplyr/nse_dplyr.Rmd +849 -0
  36. data/blogs/nse_dplyr/nse_dplyr.html +878 -0
  37. data/blogs/nse_dplyr/nse_dplyr.md +1198 -0
  38. data/blogs/nse_dplyr/nse_dplyr.pdf +0 -0
  39. data/blogs/oh_my/oh_my.html +274 -386
  40. data/blogs/oh_my/oh_my.md +208 -205
  41. data/blogs/ruby_plot/ruby_plot.Rmd +64 -84
  42. data/blogs/ruby_plot/ruby_plot.html +235 -208
  43. data/blogs/ruby_plot/ruby_plot.md +239 -34
  44. data/blogs/ruby_plot/ruby_plot.pdf +0 -0
  45. data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png +0 -0
  46. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png +0 -0
  47. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png +0 -0
  48. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png +0 -0
  49. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png +0 -0
  50. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png +0 -0
  51. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png +0 -0
  52. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png +0 -0
  53. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png +0 -0
  54. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png +0 -0
  55. data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png +0 -0
  56. data/examples/Bibliography/master.bib +50 -0
  57. data/examples/Bibliography/stats.bib +72 -0
  58. data/examples/islr/ch2.spec.rb +1 -1
  59. data/examples/islr/ch3_boston.rb +4 -4
  60. data/examples/islr/x_y_rnorm.jpg +0 -0
  61. data/examples/latex_templates/Test-acm_article/Makefile +16 -0
  62. data/examples/latex_templates/Test-acm_article/Test-acm_article.Rmd +65 -0
  63. data/examples/latex_templates/Test-acm_article/acm_proc_article-sp.cls +1670 -0
  64. data/examples/latex_templates/Test-acm_article/sensys-abstract.cls +703 -0
  65. data/examples/latex_templates/Test-acm_article/sigproc.bib +59 -0
  66. data/examples/latex_templates/Test-acs_article/Test-acs_article.Rmd +260 -0
  67. data/examples/latex_templates/Test-acs_article/Test-acs_article.pdf +0 -0
  68. data/examples/latex_templates/Test-acs_article/acs-Test-acs_article.bib +11 -0
  69. data/examples/latex_templates/Test-acs_article/acs-my_output.bib +11 -0
  70. data/examples/latex_templates/Test-acs_article/acstest.bib +17 -0
  71. data/examples/latex_templates/Test-aea_article/AEA.cls +1414 -0
  72. data/examples/latex_templates/Test-aea_article/BibFile.bib +0 -0
  73. data/examples/latex_templates/Test-aea_article/Test-aea_article.Rmd +108 -0
  74. data/examples/latex_templates/Test-aea_article/Test-aea_article.pdf +0 -0
  75. data/examples/latex_templates/Test-aea_article/aea.bst +1269 -0
  76. data/examples/latex_templates/Test-aea_article/multicol.sty +853 -0
  77. data/examples/latex_templates/Test-aea_article/references.bib +0 -0
  78. data/examples/latex_templates/Test-aea_article/setspace.sty +546 -0
  79. data/examples/latex_templates/Test-amq_article/Test-amq_article.Rmd +256 -0
  80. data/examples/latex_templates/Test-amq_article/Test-amq_article.pdf +0 -0
  81. data/examples/latex_templates/Test-amq_article/Test-amq_article.pdfsync +3397 -0
  82. data/examples/latex_templates/Test-amq_article/pics/Figure2.pdf +0 -0
  83. data/examples/latex_templates/Test-ams_article/Test-ams_article.Rmd +215 -0
  84. data/examples/latex_templates/Test-ams_article/amstest.bib +436 -0
  85. data/examples/latex_templates/Test-asa_article/Test-asa_article.Rmd +153 -0
  86. data/examples/latex_templates/Test-asa_article/Test-asa_article.pdf +0 -0
  87. data/examples/latex_templates/Test-asa_article/agsm.bst +1353 -0
  88. data/examples/latex_templates/Test-asa_article/bibliography.bib +233 -0
  89. data/examples/latex_templates/Test-ieee_article/IEEEtran.bst +2409 -0
  90. data/examples/latex_templates/Test-ieee_article/IEEEtran.cls +6346 -0
  91. data/examples/latex_templates/Test-ieee_article/Test-ieee_article.Rmd +175 -0
  92. data/examples/latex_templates/Test-ieee_article/Test-ieee_article.pdf +0 -0
  93. data/examples/latex_templates/Test-ieee_article/mybibfile.bib +20 -0
  94. data/examples/latex_templates/Test-rjournal_article/RJournal.sty +335 -0
  95. data/examples/latex_templates/Test-rjournal_article/RJreferences.bib +18 -0
  96. data/examples/latex_templates/Test-rjournal_article/RJwrapper.pdf +0 -0
  97. data/examples/latex_templates/Test-rjournal_article/Test-rjournal_article.Rmd +52 -0
  98. data/examples/latex_templates/Test-springer_article/Test-springer_article.Rmd +65 -0
  99. data/examples/latex_templates/Test-springer_article/Test-springer_article.pdf +0 -0
  100. data/examples/latex_templates/Test-springer_article/bibliography.bib +26 -0
  101. data/examples/latex_templates/Test-springer_article/spbasic.bst +1658 -0
  102. data/examples/latex_templates/Test-springer_article/spmpsci.bst +1512 -0
  103. data/examples/latex_templates/Test-springer_article/spphys.bst +1443 -0
  104. data/examples/latex_templates/Test-springer_article/svglov3.clo +113 -0
  105. data/examples/latex_templates/Test-springer_article/svjour3.cls +1431 -0
  106. data/examples/misc/moneyball.rb +1 -1
  107. data/examples/misc/subsetting.rb +37 -37
  108. data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.Rmd +73 -0
  109. data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.pdf +0 -0
  110. data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.Rmd +382 -0
  111. data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.pdf +0 -0
  112. data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.Rmd +164 -0
  113. data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.pdf +0 -0
  114. data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.Rmd +92 -0
  115. data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.pdf +0 -0
  116. data/examples/rmarkdown/svm-rmarkdown-syllabus-example/attend-grade-relationships.csv +482 -0
  117. data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.Rmd +280 -0
  118. data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.pdf +0 -0
  119. data/examples/rmarkdown/svm-xaringan-example/svm-xaringan-example.Rmd +386 -0
  120. data/lib/R_interface/r.rb +2 -2
  121. data/lib/R_interface/r_libs.R +6 -1
  122. data/lib/R_interface/r_methods.rb +12 -2
  123. data/lib/R_interface/rdata_frame.rb +8 -17
  124. data/lib/R_interface/rindexed_object.rb +1 -2
  125. data/lib/R_interface/rlist.rb +1 -0
  126. data/lib/R_interface/robject.rb +20 -23
  127. data/lib/R_interface/rpkg.rb +15 -6
  128. data/lib/R_interface/rsupport.rb +13 -19
  129. data/lib/R_interface/ruby_extensions.rb +14 -18
  130. data/lib/R_interface/rvector.rb +0 -12
  131. data/lib/gknit.rb +2 -0
  132. data/lib/gknit/draft.rb +105 -0
  133. data/lib/gknit/knitr_engine.rb +6 -37
  134. data/lib/util/exec_ruby.rb +22 -84
  135. data/lib/util/inline_file.rb +7 -3
  136. data/specs/figures/bg.jpeg +0 -0
  137. data/specs/figures/bg.png +0 -0
  138. data/specs/figures/bg.svg +2 -2
  139. data/specs/figures/dose_len.png +0 -0
  140. data/specs/figures/no_args.jpeg +0 -0
  141. data/specs/figures/no_args.png +0 -0
  142. data/specs/figures/no_args.svg +2 -2
  143. data/specs/figures/width_height.jpeg +0 -0
  144. data/specs/figures/width_height.png +0 -0
  145. data/specs/figures/width_height_units1.jpeg +0 -0
  146. data/specs/figures/width_height_units1.png +0 -0
  147. data/specs/figures/width_height_units2.jpeg +0 -0
  148. data/specs/figures/width_height_units2.png +0 -0
  149. data/specs/r_dataframe.spec.rb +184 -11
  150. data/specs/r_list.spec.rb +4 -4
  151. data/specs/r_list_apply.spec.rb +11 -10
  152. data/specs/ruby_expression.spec.rb +3 -11
  153. data/specs/tmp.rb +106 -34
  154. data/version.rb +1 -1
  155. metadata +96 -33
  156. data/bin/gknit_old_r +0 -236
  157. data/blogs/dev/dev.Rmd +0 -77
  158. data/blogs/dev/dev.md +0 -87
  159. data/blogs/dev/dev_files/figure-html/bubble-1.png +0 -0
  160. data/blogs/dev/dev_files/figure-html/diverging_bar. +0 -0
  161. data/blogs/dev/dev_files/figure-html/diverging_bar.png +0 -0
  162. data/blogs/dplyr/dplyr.rb +0 -63
  163. data/blogs/galaaz_ggplot/galaaz_ggplot.aux +0 -43
  164. data/blogs/galaaz_ggplot/galaaz_ggplot.log +0 -640
  165. data/blogs/galaaz_ggplot/galaaz_ggplot.out +0 -10
  166. data/blogs/galaaz_ggplot/galaaz_ggplot.tex +0 -481
  167. data/blogs/galaaz_ggplot/midwest.png +0 -0
  168. data/blogs/galaaz_ggplot/scatter_plot.png +0 -0
  169. data/blogs/ruby_plot/ruby_plot.Rmd_external_figs +0 -662
  170. data/blogs/ruby_plot/ruby_plot.tex +0 -1077
  171. data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg +0 -57
  172. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg +0 -106
  173. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg +0 -110
  174. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg +0 -174
  175. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg +0 -236
  176. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.svg +0 -296
  177. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg +0 -236
  178. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg +0 -218
  179. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg +0 -128
  180. data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg +0 -150
  181. data/examples/paper/paper.rb +0 -36
@@ -75,11 +75,11 @@ keyword 'attr_reader' and a colom before the variables name:
75
75
 
76
76
 
77
77
 
78
- ```
79
- ## class Trajectories
80
- ## attr_reader :times
81
- ## attr_reader :matrix
82
- ## end
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
- ## @traj = Trajectories.new
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
- ## puts @traj
98
+ ```ruby
99
+ puts @traj
100
100
  ```
101
101
 
102
102
  ```
103
- ## #<GalaazUtil::Trajectories:0x628>
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
- ## puts @traj.times
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
- ## 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
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
- ## # 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))
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
- ## puts @traj.times
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
- ## puts @traj2.times
190
- ## puts
191
- ## puts @traj2.matrix
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
- ## @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)))
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
- ## puts @trajCochin.times
255
- ## puts
256
- ## puts @trajCochin.matrix
257
- ## puts
258
- ## puts @trajStAnne.times
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
- ## 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
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
- ## puts @traj_bis.times
314
- ## puts
315
- ## puts @traj_bis.matrix
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
- ## class TrajectoriesBis
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
- ## puts @traj_bis.times
355
- ## puts
356
- ## puts @traj_bis.matrix
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
- ## 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
- ## #----------------------------------------------------------
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
- ## @trajCochin.print
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
- ## 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
545
- ```
546
-
547
-
548
- ```
549
- ## @trajStAnne.show
550
- ```
551
-
552
- ```
553
- ## *** Class Trajectories, method Show ***
554
- ## times = [1] 1 2 3 4 5 6 7 8 9 10 12 14 16 18 20 22 24 26 28 30 32
555
- ## * Traj (limited to a matrix 10x10) =
556
- ## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
557
- ## [1,] "16.20" "15.61" "16.22" "16.34" "16.16" "16.75" "16.72" "17.25"
558
- ## [2,] "15.65" "16.44" "16.32" "16.58" "16.78" "17.04" "17.00" "16.88"
559
- ## [3,] "16.12" "16.23" "16.42" "16.51" "16.67" "16.77" "17.05" "16.98"
560
- ## [4,] "15.82" "16.22" "16.48" "16.79" "16.52" "16.71" "16.90" "17.06"
561
- ## [5,] "15.92" "16.39" "16.33" "16.61" "16.56" "16.81" "16.76" "17.25"
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
- ## @empty_traj = Trajectories.new
587
+ ```ruby
588
+ @empty_traj = Trajectories.new
587
589
  ```
588
590
 
589
591
 
590
- ```
591
- ## @empty_traj.show
592
+ ```ruby
593
+ @empty_traj.show
592
594
  ```
593
595
 
594
596
  ```
595
- ## undefined method `nrow' for nil:NilClass
597
+ ## Message:
598
+ ## undefined method `nrow' for nil:NilClass
596
599
  ```
597
600