galaaz 0.4.10 → 2.0.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 (391) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/LICENSE +0 -0
  4. data/README.md +3123 -882
  5. data/Rakefile +62 -41
  6. data/bin/galaaz-bootstrap +137 -0
  7. data/bin/galaaz-jruby +14 -0
  8. data/bin/galaaz_jruby_env.inc.sh +6 -0
  9. data/bin/gbookdown +64 -0
  10. data/bin/gknit +223 -6
  11. data/bin/gknit-draft +105 -0
  12. data/bin/gknit-draft.rb +28 -0
  13. data/bin/gknit_Rscript +127 -0
  14. data/bin/grun +27 -1
  15. data/bin/gstudio +49 -4
  16. data/bin/{gstudio.rb → gstudio_irb.rb} +0 -0
  17. data/bin/gstudio_pry.rb +7 -0
  18. data/bin/install-tinytex +6 -0
  19. data/bin/run_all_rspec +43 -0
  20. data/bin/run_example +14 -0
  21. data/bin/run_old_rspec +19 -0
  22. data/bin/run_rspec +23 -0
  23. data/bin/run_rspec_subset +38 -0
  24. data/bin/run_slow_rspec +19 -0
  25. data/blogs/R-on-Rails-Planning-Document.md +940 -0
  26. data/blogs/README.md +100 -0
  27. data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +38 -66
  28. data/blogs/galaaz_ggplot/galaaz_ggplot.log +754 -0
  29. data/blogs/galaaz_ggplot/galaaz_ggplot.md +364 -0
  30. data/blogs/galaaz_ggplot/galaaz_ggplot.tex +607 -0
  31. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/midwest_rb.png +0 -0
  32. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/scatter_plot_rb.png +0 -0
  33. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/midwest_rb.png +0 -0
  34. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/scatter_plot_rb.png +0 -0
  35. data/blogs/galaaz_ggplot/midwest.Rmd +3 -3
  36. data/blogs/galaaz_ggplot/midwest_external_png +0 -0
  37. data/blogs/gknit/gknit.Rmd +52 -55
  38. data/blogs/gknit/gknit.md +94 -94
  39. data/blogs/gknit/gknit_files/figure-html/bubble-1.png +0 -0
  40. data/blogs/gknit/gknit_files/figure-html/diverging_bar.png +0 -0
  41. data/blogs/gknit/lst.rds +0 -0
  42. data/blogs/gknit/model.rb +1 -1
  43. data/blogs/gknit/stats.bib +0 -0
  44. data/blogs/manual/include_model_local_repro.Rmd +14 -0
  45. data/blogs/manual/include_model_local_repro.md +75 -0
  46. data/blogs/manual/lst.rds +0 -0
  47. data/blogs/manual/manual.Rmd +1582 -196
  48. data/blogs/manual/manual.log +1786 -0
  49. data/blogs/manual/manual.md +3107 -890
  50. data/blogs/manual/manual.tex +3018 -1086
  51. data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
  52. data/blogs/manual/manual_files/figure-html/diverging_bar.png +0 -0
  53. data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
  54. data/blogs/manual/model.rb +41 -0
  55. data/blogs/nse_dplyr/nse_dplyr.Rmd +277 -151
  56. data/blogs/nse_dplyr/nse_dplyr.log +928 -0
  57. data/blogs/nse_dplyr/nse_dplyr.md +457 -293
  58. data/blogs/oh_my/not_so.rb +0 -0
  59. data/blogs/oh_my/oh_my.Rmd +1234 -25
  60. data/blogs/oh_my/oh_my.log +804 -0
  61. data/blogs/oh_my/oh_my.md +1808 -228
  62. data/blogs/oh_my/oh_my.tex +821 -0
  63. data/blogs/oh_my/old.Rmd +15 -14
  64. data/blogs/ruby_plot/ruby_plot.Rmd +58 -82
  65. data/blogs/ruby_plot/ruby_plot.log +885 -0
  66. data/blogs/ruby_plot/ruby_plot.md +71 -103
  67. data/blogs/ruby_plot/ruby_plot.tex +940 -0
  68. data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png +0 -0
  69. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png +0 -0
  70. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png +0 -0
  71. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png +0 -0
  72. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png +0 -0
  73. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png +0 -0
  74. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png +0 -0
  75. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png +0 -0
  76. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png +0 -0
  77. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png +0 -0
  78. data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png +0 -0
  79. data/blogs/ruby_plot/ruby_plot_files/figure-latex/dose_len.png +0 -0
  80. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
  81. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
  82. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
  83. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
  84. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
  85. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
  86. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
  87. data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
  88. data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
  89. data/blogs/ruby_plot/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
  90. data/blogs/test/test.Rmd +14 -0
  91. data/examples/50Plots_MasterList/Images/midwest-scatterplot.PNG +0 -0
  92. data/examples/50Plots_MasterList/ScatterPlot.rb +0 -0
  93. data/examples/50Plots_MasterList/scatter_plot.rb +0 -0
  94. data/examples/Bibliography/master.bib +50 -0
  95. data/examples/Bibliography/stats.bib +72 -0
  96. data/examples/R/calc.R +0 -0
  97. data/examples/R/java_interop.R +0 -0
  98. data/examples/bioconductor_deseq2_airway/Documentation/DESeq2-airway-walkthrough.md +56 -0
  99. data/examples/bioconductor_deseq2_airway/bench_galaaz_three_same_process.rb +53 -0
  100. data/examples/bioconductor_deseq2_airway/bench_r_three_same_process.R +34 -0
  101. data/examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb +33 -0
  102. data/examples/bioconductor_deseq2_airway/deseq2_airway_galaaz_optimized.rb +34 -0
  103. data/examples/bioconductor_deseq2_airway/deseq2_airway_minimal.R +30 -0
  104. data/examples/bioconductor_deseq2_airway/deseq2_airway_pipeline_for_bench.R +36 -0
  105. data/examples/islr/all.rb +13 -0
  106. data/examples/islr/ch2.spec.rb +37 -7
  107. data/examples/islr/ch3.spec.rb +11 -2
  108. data/examples/islr/ch3_boston.rb +27 -0
  109. data/examples/islr/ch3_multiple_regression.rb +0 -0
  110. data/examples/islr/ch6.spec.rb +24 -1
  111. data/examples/islr/x_y_rnorm.jpg +0 -0
  112. data/examples/latex_templates/Test-acm_article/Makefile +16 -0
  113. data/examples/latex_templates/Test-acm_article/Test-acm_article.Rmd +65 -0
  114. data/examples/latex_templates/Test-acm_article/acm_proc_article-sp.cls +1670 -0
  115. data/examples/latex_templates/Test-acm_article/sensys-abstract.cls +703 -0
  116. data/examples/latex_templates/Test-acm_article/sigproc.bib +59 -0
  117. data/examples/latex_templates/Test-acs_article/Test-acs_article.Rmd +260 -0
  118. data/examples/latex_templates/Test-acs_article/acs-Test-acs_article.bib +11 -0
  119. data/examples/latex_templates/Test-acs_article/acs-my_output.bib +11 -0
  120. data/examples/latex_templates/Test-acs_article/acstest.bib +17 -0
  121. data/examples/latex_templates/Test-aea_article/AEA.cls +1414 -0
  122. data/{blogs/gknit/marshal.dump → examples/latex_templates/Test-aea_article/BibFile.bib} +0 -0
  123. data/examples/latex_templates/Test-aea_article/Test-aea_article.Rmd +108 -0
  124. data/examples/latex_templates/Test-aea_article/aea.bst +1269 -0
  125. data/examples/latex_templates/Test-aea_article/multicol.sty +853 -0
  126. data/examples/latex_templates/Test-aea_article/references.bib +0 -0
  127. data/examples/latex_templates/Test-aea_article/setspace.sty +546 -0
  128. data/examples/latex_templates/Test-amq_article/Test-amq_article.Rmd +256 -0
  129. data/examples/latex_templates/Test-amq_article/Test-amq_article.pdfsync +3397 -0
  130. data/examples/latex_templates/Test-ams_article/Test-ams_article.Rmd +215 -0
  131. data/examples/latex_templates/Test-ams_article/amstest.bib +436 -0
  132. data/examples/latex_templates/Test-asa_article/Test-asa_article.Rmd +153 -0
  133. data/examples/latex_templates/Test-asa_article/agsm.bst +1353 -0
  134. data/examples/latex_templates/Test-asa_article/bibliography.bib +233 -0
  135. data/examples/latex_templates/Test-ieee_article/IEEEtran.bst +2409 -0
  136. data/examples/latex_templates/Test-ieee_article/IEEEtran.cls +6346 -0
  137. data/examples/latex_templates/Test-ieee_article/Test-ieee_article.Rmd +175 -0
  138. data/examples/latex_templates/Test-ieee_article/mybibfile.bib +20 -0
  139. data/examples/latex_templates/Test-rjournal_article/RJournal.sty +335 -0
  140. data/examples/latex_templates/Test-rjournal_article/RJreferences.bib +18 -0
  141. data/examples/latex_templates/Test-rjournal_article/Test-rjournal_article.Rmd +52 -0
  142. data/examples/latex_templates/Test-springer_article/Test-springer_article.Rmd +65 -0
  143. data/examples/latex_templates/Test-springer_article/bibliography.bib +26 -0
  144. data/examples/latex_templates/Test-springer_article/spbasic.bst +1658 -0
  145. data/examples/latex_templates/Test-springer_article/spmpsci.bst +1512 -0
  146. data/examples/latex_templates/Test-springer_article/spphys.bst +1443 -0
  147. data/examples/latex_templates/Test-springer_article/svglov3.clo +113 -0
  148. data/examples/latex_templates/Test-springer_article/svjour3.cls +1431 -0
  149. data/examples/misc/baseball.csv +0 -0
  150. data/examples/misc/ggplot.rb +3 -2
  151. data/examples/misc/moneyball.rb +0 -0
  152. data/examples/misc/subsetting.rb +0 -0
  153. data/examples/multithread_shards_to_r/shards_to_r.rb +67 -0
  154. data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.Rmd +73 -0
  155. data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.Rmd +382 -0
  156. data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.Rmd +164 -0
  157. data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.Rmd +92 -0
  158. data/examples/rmarkdown/svm-rmarkdown-syllabus-example/attend-grade-relationships.csv +482 -0
  159. data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.Rmd +280 -0
  160. data/examples/rmarkdown/svm-xaringan-example/svm-xaringan-example.Rmd +386 -0
  161. data/examples/sthda_ggplot/README.md +0 -0
  162. data/examples/sthda_ggplot/RUN.md +41 -0
  163. data/examples/sthda_ggplot/all.rb +0 -0
  164. data/examples/sthda_ggplot/one_variable_continuous/density_gg.rb +0 -0
  165. data/examples/sthda_ggplot/one_variable_continuous/geom_area.rb +0 -0
  166. data/examples/sthda_ggplot/one_variable_continuous/geom_density.rb +2 -0
  167. data/examples/sthda_ggplot/one_variable_continuous/geom_dotplot.rb +0 -0
  168. data/examples/sthda_ggplot/one_variable_continuous/geom_freqpoly.rb +0 -0
  169. data/examples/sthda_ggplot/one_variable_continuous/geom_histogram.rb +0 -0
  170. data/examples/sthda_ggplot/one_variable_continuous/histogram_density.rb +0 -0
  171. data/examples/sthda_ggplot/one_variable_continuous/stat.rb +0 -0
  172. data/examples/sthda_ggplot/one_variable_discrete/bar.rb +0 -0
  173. data/examples/sthda_ggplot/qplots/box_violin_dot.rb +0 -0
  174. data/examples/sthda_ggplot/qplots/scatter_plots.rb +0 -0
  175. data/examples/sthda_ggplot/scatter_gg.rb +0 -0
  176. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_bin2d.rb +0 -0
  177. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_density2d.rb +0 -0
  178. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_hex.rb +0 -0
  179. data/examples/sthda_ggplot/two_variables_cont_cont/geom_point.rb +0 -0
  180. data/examples/sthda_ggplot/two_variables_cont_cont/geom_smooth.rb +0 -0
  181. data/examples/sthda_ggplot/two_variables_cont_cont/misc.rb +0 -0
  182. data/examples/sthda_ggplot/two_variables_cont_function/geom_area.rb +4 -3
  183. data/examples/sthda_ggplot/two_variables_disc_cont/geom_bar.rb +0 -0
  184. data/examples/sthda_ggplot/two_variables_disc_cont/geom_boxplot.rb +0 -0
  185. data/examples/sthda_ggplot/two_variables_disc_cont/geom_dotplot.rb +0 -0
  186. data/examples/sthda_ggplot/two_variables_disc_cont/geom_jitter.rb +0 -0
  187. data/examples/sthda_ggplot/two_variables_disc_cont/geom_line.rb +0 -0
  188. data/examples/sthda_ggplot/two_variables_disc_cont/geom_violin.rb +0 -0
  189. data/examples/sthda_ggplot/two_variables_disc_disc/geom_jitter.rb +0 -0
  190. data/examples/sthda_ggplot/two_variables_error/geom_crossbar.rb +0 -0
  191. data/ext/new_bridge/Makefile +46 -0
  192. data/ext/new_bridge/galaaz_gatekeeper_phase0.cpp +12 -0
  193. data/ext/new_bridge/galaaz_gatekeeper_phase1.cpp +1639 -0
  194. data/lib/R_interface/galaaz_device.R +20 -0
  195. data/lib/R_interface/include_engine.R +109 -0
  196. data/lib/R_interface/new_bridge_adapter.rb +824 -0
  197. data/lib/R_interface/r.rb +177 -25
  198. data/lib/R_interface/r_arrow.rb +113 -0
  199. data/lib/R_interface/r_libs.R +4 -4
  200. data/lib/R_interface/r_methods.rb +13 -116
  201. data/lib/R_interface/r_module_s.rb +0 -0
  202. data/lib/R_interface/rbinary_operators.rb +20 -2
  203. data/lib/R_interface/rclosure.rb +5 -1
  204. data/lib/R_interface/rdata_frame.rb +34 -70
  205. data/lib/R_interface/rdevice.rb +125 -0
  206. data/lib/R_interface/rdevices.R +0 -0
  207. data/lib/R_interface/renvironment.rb +10 -4
  208. data/lib/R_interface/rexpression.rb +5 -1
  209. data/lib/R_interface/rindexed_object.rb +41 -13
  210. data/lib/R_interface/rlanguage.rb +20 -62
  211. data/lib/R_interface/rlist.rb +115 -25
  212. data/lib/R_interface/rlogical_operators.rb +0 -0
  213. data/lib/R_interface/rmatrix.rb +2 -11
  214. data/lib/R_interface/rmd_indexed_object.rb +5 -1
  215. data/lib/R_interface/robject.rb +348 -290
  216. data/lib/R_interface/rpkg.rb +1 -0
  217. data/lib/R_interface/rsupport.rb +610 -331
  218. data/lib/R_interface/rsupport_scope.rb +2 -1
  219. data/lib/R_interface/rsymbol.rb +50 -0
  220. data/lib/R_interface/ruby_callback.rb +2 -3
  221. data/lib/R_interface/ruby_extensions.rb +225 -175
  222. data/lib/R_interface/runary_operators.rb +0 -0
  223. data/lib/R_interface/rvector.rb +147 -31
  224. data/lib/galaaz.rb +0 -0
  225. data/lib/galaaz_jruby.rb +22 -0
  226. data/lib/gknit/diagnostics.rb +50 -0
  227. data/lib/gknit/draft.rb +111 -0
  228. data/lib/gknit/include_engine.rb +15 -7
  229. data/lib/gknit/knitr_engine.rb +223 -107
  230. data/lib/gknit/rb_engine.rb +3 -3
  231. data/lib/gknit/ruby_engine.rb +0 -0
  232. data/lib/gknit.rb +3 -0
  233. data/lib/new_bridge/bootstrap/windows_bootstrap.rb +285 -0
  234. data/lib/new_bridge/envelope.rb +51 -0
  235. data/lib/new_bridge/eval_result.rb +26 -0
  236. data/lib/new_bridge/framing.rb +39 -0
  237. data/lib/new_bridge/instance_pool_client.rb +38 -0
  238. data/lib/new_bridge/r_instance_manager.rb +404 -0
  239. data/lib/new_bridge/session_client.rb +530 -0
  240. data/lib/new_bridge/tcp_framed.rb +44 -0
  241. data/lib/new_bridge.rb +9 -0
  242. data/lib/util/exec_ruby.rb +95 -46
  243. data/lib/util/inline_file.rb +35 -30
  244. data/new_bridge_specs/benchmark_phase5_5_unboxing_spec.rb +96 -0
  245. data/new_bridge_specs/eval_r_async_spec.rb +113 -0
  246. data/new_bridge_specs/integration_phase5_1_concurrent_spec.rb +50 -0
  247. data/new_bridge_specs/integration_phase5_1_eval_spec.rb +16 -0
  248. data/new_bridge_specs/integration_phase5_1_r_api_spec.rb +25 -0
  249. data/new_bridge_specs/integration_phase5_1_smoke_spec.rb +31 -0
  250. data/new_bridge_specs/integration_phase5_2_dataframe_unboxing_spec.rb +19 -0
  251. data/new_bridge_specs/integration_phase5_2_handle_eval_unboxing_spec.rb +25 -0
  252. data/new_bridge_specs/integration_phase5_3_callback_args_spec.rb +28 -0
  253. data/new_bridge_specs/integration_phase5_3_callback_error_spec.rb +22 -0
  254. data/new_bridge_specs/integration_phase5_3_callback_timeout_spec.rb +28 -0
  255. data/new_bridge_specs/integration_phase5_3_callbacks_smoke_spec.rb +22 -0
  256. data/new_bridge_specs/integration_phase5_3_edge_cases_spec.rb +52 -0
  257. data/new_bridge_specs/integration_phase5_3_nested_spec.rb +30 -0
  258. data/new_bridge_specs/integration_phase5_4_concurrent_sessions_spec.rb +53 -0
  259. data/new_bridge_specs/integration_phase5_4_nested_session_callbacks_spec.rb +49 -0
  260. data/new_bridge_specs/integration_phase5_4_session_routing_spec.rb +38 -0
  261. data/new_bridge_specs/integration_phase5_5_stress_concurrency_spec.rb +52 -0
  262. data/new_bridge_specs/integration_phase5_5_unbox_walk_spec.rb +46 -0
  263. data/new_bridge_specs/phase0_protocol_spec.rb +96 -0
  264. data/new_bridge_specs/phase1_req_ret_spec.rb +66 -0
  265. data/new_bridge_specs/phase2_multi_instance_spec.rb +67 -0
  266. data/new_bridge_specs/phase3_callbacks_spec.rb +71 -0
  267. data/new_bridge_specs/phase4_2_hardening_spec.rb +252 -0
  268. data/new_bridge_specs/phase4_3_r_instance_manager_spec.rb +85 -0
  269. data/new_bridge_specs/phase4_nested_callbacks_spec.rb +123 -0
  270. data/r_requires/ggplot.rb +0 -0
  271. data/r_requires/knitr.rb +0 -0
  272. data/specs/all.rb +15 -11
  273. data/specs/arrow_from_ruby_batches_spec.rb +50 -0
  274. data/specs/arrow_semantics_spec.rb +64 -0
  275. data/specs/bridge_concurrent_spec.rb +46 -0
  276. data/specs/bridge_nested_spec.rb +25 -0
  277. data/specs/dataframe_semantics_spec.rb +122 -0
  278. data/specs/dataframe_single_index_logical_filter_spec.rb +21 -0
  279. data/specs/dispatch_probe_cache_spec.rb +38 -0
  280. data/specs/dispatch_probe_error_class_fallback_spec.rb +20 -0
  281. data/specs/dispatch_probe_fallback_spec.rb +18 -0
  282. data/specs/environment_semantics_spec.rb +89 -0
  283. data/specs/field_access_spec.rb +31 -0
  284. data/specs/figures/bg.jpeg +0 -0
  285. data/specs/figures/bg.png +0 -0
  286. data/specs/figures/bg.svg +168 -57
  287. data/specs/figures/dose_len.png +0 -0
  288. data/specs/figures/no_args.jpeg +0 -0
  289. data/specs/figures/no_args.png +0 -0
  290. data/specs/figures/no_args.svg +168 -57
  291. data/specs/figures/width_height.jpeg +0 -0
  292. data/specs/figures/width_height.png +0 -0
  293. data/specs/figures/width_height_units1.jpeg +0 -0
  294. data/specs/figures/width_height_units1.png +0 -0
  295. data/specs/figures/width_height_units2.jpeg +0 -0
  296. data/specs/figures/width_height_units2.png +0 -0
  297. data/specs/formula_semantics_spec.rb +81 -0
  298. data/specs/galaaz_util_exec_ruby_spec.rb +85 -0
  299. data/specs/galaaz_util_inline_file_spec.rb +54 -0
  300. data/specs/gknit_cli_option_permutation_spec.rb +24 -0
  301. data/specs/gknit_include_engine_spec.rb +72 -0
  302. data/specs/gknit_install_timeout_report_spec.rb +69 -0
  303. data/specs/gknit_internal_error_report_spec.rb +57 -0
  304. data/specs/gknit_vector_map_output_spec.rb +59 -0
  305. data/specs/globalenv_guardrail_spec.rb +52 -0
  306. data/specs/language_expression_semantics_spec.rb +145 -0
  307. data/specs/list_semantics_spec.rb +111 -0
  308. data/specs/new_bridge_bulk_dataframe_transfer_spec.rb +44 -0
  309. data/specs/new_bridge_bulk_vector_transfer_spec.rb +73 -0
  310. data/specs/new_bridge_callback_timeout_spec.rb +69 -0
  311. data/specs/new_bridge_eval_r_fallback_spec.rb +55 -0
  312. data/specs/nil_null_spec.rb +42 -0
  313. data/specs/object_build_phase2_spec.rb +53 -0
  314. data/specs/phase1_callback_bridge_spec.rb +84 -0
  315. data/specs/phase2_gknit_generic_rendering_guardrail_spec.rb +46 -0
  316. data/specs/phase2_gknit_no_raw_code_leakage_spec.rb +43 -0
  317. data/specs/phase3_gknit_generic_graphics_capture_spec.rb +71 -0
  318. data/specs/plot_device_semantics_spec.rb +28 -0
  319. data/specs/plot_snapshot_semantics_spec.rb +58 -0
  320. data/specs/protocol_result_spec.rb +236 -0
  321. data/specs/r_batch_fail_fast_spec.rb +47 -0
  322. data/specs/r_bridge_bootstrap_spec.rb +11 -0
  323. data/specs/r_devices.spec.rb +1 -1
  324. data/specs/r_eval.spec.rb +16 -18
  325. data/specs/r_function.spec.rb +1 -1
  326. data/specs/r_instance_manager_spec.rb +285 -0
  327. data/specs/r_list_apply.spec.rb +15 -15
  328. data/specs/r_matrix.spec.rb +0 -0
  329. data/specs/r_nse.spec.rb +5 -5
  330. data/specs/r_object_send_dispatch_spec.rb +13 -0
  331. data/specs/r_vector_comparator_spec.rb +8 -0
  332. data/specs/r_vector_creation.spec.rb +0 -0
  333. data/specs/r_vector_functions.spec.rb +0 -0
  334. data/specs/r_vector_object.spec.rb +0 -0
  335. data/specs/r_vector_operators.spec.rb +0 -0
  336. data/specs/r_vector_structured_scalar_reads_spec.rb +35 -0
  337. data/specs/r_vector_subsetting.spec.rb +0 -0
  338. data/specs/range_helper_spec.rb +21 -0
  339. data/specs/rsupport_scope_spec.rb +28 -0
  340. data/specs/rsupport_var_name_thread_safety_spec.rb +24 -0
  341. data/specs/scalar_character_spec.rb +44 -0
  342. data/specs/scoped_symbol_dsl_refinement_spec.rb +40 -0
  343. data/specs/session_env_bridge_spec.rb +25 -0
  344. data/specs/simplecov_bootstrap_spec.rb +10 -0
  345. data/specs/spec_helper.rb +10 -0
  346. data/specs/tmp.rb +41 -20
  347. data/specs/unboxing_recursion_regression_spec.rb +30 -0
  348. data/specs/unboxing_spec.rb +49 -0
  349. data/specs/verify_callbacks.rb +42 -0
  350. data/sty/galaaz.sty +0 -0
  351. data/version.rb +1 -1
  352. metadata +239 -71
  353. data/blogs/galaaz_ggplot/galaaz_ggplot.aux +0 -41
  354. data/blogs/galaaz_ggplot/galaaz_ggplot.html +0 -705
  355. data/blogs/galaaz_ggplot/galaaz_ggplot.out +0 -10
  356. data/blogs/galaaz_ggplot/galaaz_ggplot.pdf +0 -0
  357. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/midwest_rb.pdf +0 -0
  358. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/scatter_plot_rb.pdf +0 -0
  359. data/blogs/galaaz_ggplot/midwest.html +0 -188
  360. data/blogs/gknit/gknit.html +0 -2266
  361. data/blogs/gknit/gknit.pdf +0 -0
  362. data/blogs/gknit/gknit.tex +0 -1358
  363. data/blogs/manual/graph.rb +0 -29
  364. data/blogs/manual/manual.html +0 -2995
  365. data/blogs/manual/manual.pdf +0 -0
  366. data/blogs/manual/manual_files/figure-latex/diverging_bar.pdf +0 -0
  367. data/blogs/nse_dplyr/nse_dplyr.html +0 -960
  368. data/blogs/nse_dplyr/nse_dplyr.pdf +0 -0
  369. data/blogs/nse_dplyr/nse_dplyr.tex +0 -1373
  370. data/blogs/oh_my/oh_my.html +0 -680
  371. data/blogs/ruby_plot/ruby_plot.Rmd_external_figs +0 -662
  372. data/blogs/ruby_plot/ruby_plot.html +0 -729
  373. data/blogs/ruby_plot/ruby_plot.pdf +0 -0
  374. data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg +0 -57
  375. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg +0 -106
  376. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg +0 -110
  377. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg +0 -174
  378. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg +0 -236
  379. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.svg +0 -296
  380. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg +0 -236
  381. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg +0 -218
  382. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg +0 -128
  383. data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg +0 -150
  384. data/examples/paper/paper.rb +0 -36
  385. data/specs/r_dataframe.spec.rb +0 -379
  386. data/specs/r_environment.spec.rb +0 -140
  387. data/specs/r_formula.spec.rb +0 -232
  388. data/specs/r_language.spec.rb +0 -112
  389. data/specs/r_list.spec.rb +0 -293
  390. data/specs/r_plots.spec.rb +0 -72
  391. data/specs/ruby_expression.spec.rb +0 -315
data/blogs/gknit/gknit.md CHANGED
@@ -3,17 +3,18 @@ title: "How to do reproducible research in Ruby with gKnit"
3
3
  author:
4
4
  - "Rodrigo Botafogo"
5
5
  - "Daniel Mossé - University of Pittsburgh"
6
- tags: [Tech, Data Science, Ruby, R, GraalVM]
7
- date: "29/04/2019"
6
+ tags: [Tech, Data Science, Ruby, R, JRuby, "GNU R", Galaaz, gKnit, knitr]
7
+ date: "29/04/2019 (narrative updated for Galaaz 2.0, 2026)"
8
8
  bibliography: stats.bib
9
9
  output:
10
- html_document:
11
- self_contained: true
12
- keep_md: true
13
10
  pdf_document:
14
11
  includes:
15
12
  in_header: ["../../sty/galaaz.sty"]
16
13
  number_sections: yes
14
+ html_document:
15
+ self_contained: true
16
+ keep_md: true
17
+ biblio-style: apsr
17
18
  ---
18
19
 
19
20
 
@@ -37,7 +38,7 @@ single document or set of documents that when distributed to peers could be reru
37
38
  the same output and reports.
38
39
 
39
40
  The R community has put a great deal of effort in reproducible research. In 2002, Sweave was
40
- introduced and it allowed mixing R code with Latex generating high quality PDF documents. A
41
+ introduced and it allowed mixing R code with LaTeX, generating high-quality PDF documents. A
41
42
  Sweave document could include code, the results of executing the code, graphics and text
42
43
  such that it contained the whole narrative to reproduce the research. In
43
44
  2012, Knitr, developed by Yihui Xie from RStudio was released to replace Sweave and to
@@ -46,7 +47,7 @@ were necessary for Sweave.
46
47
 
47
48
  With Knitr, __R markdown__ was also developed, an extension to the
48
49
  Markdown format. With __R markdown__ and Knitr it is possible to generate reports in a multitude
49
- of formats such as HTML, markdown, Latex, PDF, dvi, etc. __R markdown__ also allows the use of
50
+ of formats such as HTML, Markdown, LaTeX, PDF, DVI, etc. __R markdown__ also allows the use of
50
51
  multiple programming languages such as R, Ruby, Python, etc. in the same document.
51
52
 
52
53
  In __R markdown__, text is interspersed with
@@ -67,14 +68,14 @@ create a list, then we would need to save it to file, but to save it, we need so
67
68
  data into a binary format:
68
69
 
69
70
 
70
- ```ruby
71
+ ``` ruby
71
72
  lst = R.list(a: 1, b: 2, c: 3)
72
73
  lst.saveRDS("lst.rds")
73
74
  ```
74
75
  then, on the next chunk, where variable 'lst' is used, we need to read back it's value
75
76
 
76
77
 
77
- ```ruby
78
+ ``` ruby
78
79
  lst = R.readRDS("lst.rds")
79
80
  puts lst
80
81
  ```
@@ -97,13 +98,13 @@ this problem, it is very rare to see any __R markdown__ document in the Ruby com
97
98
  When variables can be used accross chunks, then no overhead is needed:
98
99
 
99
100
 
100
- ```ruby
101
+ ``` ruby
101
102
  lst = R.list(a: 1, b: 2, c: 3)
102
103
  # any other code can be added here
103
104
  ```
104
105
 
105
106
 
106
- ```ruby
107
+ ``` ruby
107
108
  puts lst
108
109
  ```
109
110
 
@@ -119,8 +120,8 @@ puts lst
119
120
  ```
120
121
 
121
122
  In the Python community, the same effort to have code and text in an integrated environment
122
- started around the first decade of 2000. In 2006 iPython 0.7.2 was released. In 2014,
123
- Fernando Pérez, spun off project Jupyter from iPython creating a web-based interactive
123
+ started around the first decade of the 2000s. In 2006 IPython 0.7.2 was released. In 2014,
124
+ Fernando Pérez spun off the Jupyter project from IPython, creating a web-based interactive
124
125
  computation environment. Jupyter can now be used with many languages, including Ruby with the
125
126
  iruby gem (https://github.com/SciRuby/iruby). In order to have multiple languages in a Jupyter
126
127
  notebook the SoS kernel was developed (https://vatlab.github.io/sos-docs/).
@@ -132,15 +133,14 @@ written both in Ruby and/or R and output it in any of the available formats of _
132
133
  allows ruby developers to do literate programming and reproducible research by allowing them to
133
134
  have in a single document, text and code.
134
135
 
135
- gKnit runs atop of GraalVM, and Galaaz (an integration
136
- library between Ruby and R - see bellow). In gKnit, Ruby variables are persisted between
137
- chunks, making it an ideal solution for literate programming in this language. Also,
138
- since it is based on Galaaz, Ruby chunks can have access to R variables and Polyglot Programming
139
- with Ruby and R is quite natural.
136
+ gKnit runs with **JRuby**, **GNU R**, and **Galaaz** (the integration layer between Ruby and R—see below).
137
+ Knitr and **R Markdown** orchestrate the document; Galaaz’s engine keeps **Ruby state across chunks**
138
+ and talks to R through the **bridge**. Ruby chunks can read and update R variables (`~R[:name]`, `R.*`)
139
+ without GraalVM-style polyglot interop.
140
140
 
141
141
  Galaaz has already been describe in the following posts:
142
142
 
143
- * https://towardsdatascience.com/ruby-plotting-with-galaaz-an-example-of-tightly-coupling-ruby-and-r-in-graalvm-520b69e21021.
143
+ * https://towardsdatascience.com/ruby-plotting-with-galaaz-an-example-of-tightly-coupling-ruby-and-r-in-graalvm-520b69e21021 (older GraalVM-era article; plotting ideas still apply).
144
144
  * https://medium.freecodecamp.org/how-to-make-beautiful-ruby-plots-with-galaaz-320848058857
145
145
 
146
146
  This is not a blog post on __R markdown__, and the interested user is directed to the following links
@@ -155,7 +155,7 @@ gKnitting Ruby and R documents quickly.
155
155
  ## The Yaml header
156
156
 
157
157
  An __R markdown__ document should start with a Yaml header and be stored in a file with
158
- '.Rmd' extension. This document has the following header for gKitting an HTML document.
158
+ '.Rmd' extension. This document has the following header for gKnitting an HTML document.
159
159
 
160
160
  ```
161
161
  ---
@@ -163,7 +163,7 @@ title: "How to do reproducible research in Ruby with gKnit"
163
163
  author:
164
164
  - "Rodrigo Botafogo"
165
165
  - "Daniel Mossé - University of Pittsburgh"
166
- tags: [Tech, Data Science, Ruby, R, GraalVM]
166
+ tags: [Tech, Data Science, Ruby, R, JRuby, "GNU R", Galaaz]
167
167
  date: "20/02/2019"
168
168
  output:
169
169
  html_document:
@@ -222,7 +222,7 @@ Running and executing Ruby and R code is actually what really interests us is th
222
222
  Inserting a code chunk is done by adding code in a block delimited by three back ticks
223
223
  followed by an open
224
224
  curly brace ('{') followed with the engine name (r, ruby, rb, include, ...), an
225
- any optional chunk_label and options, as shown bellow:
225
+ any optional chunk_label and options, as shown below:
226
226
 
227
227
  ````
228
228
  ```{engine_name [chunk_label], [chunk_options]}
@@ -242,7 +242,7 @@ print(vec)
242
242
  If this block is added to an __R markdown__ document and gKnitted the result will be:
243
243
 
244
244
 
245
- ```r
245
+ ``` r
246
246
  vec <- c(1, 2, 3)
247
247
  print(vec)
248
248
  ```
@@ -290,7 +290,7 @@ presentation we will not show chunk definitions any longer.
290
290
 
291
291
 
292
292
 
293
- ```r
293
+ ``` r
294
294
  r_vec <- c(1, 2, 3, 4, 5)
295
295
 
296
296
  reduce_sum <- function(...) {
@@ -301,7 +301,7 @@ reduce_sum <- function(...) {
301
301
  We can, possibly in another chunk, access the vector and call the function as follows:
302
302
 
303
303
 
304
- ```r
304
+ ``` r
305
305
  print(r_vec)
306
306
  ```
307
307
 
@@ -309,7 +309,7 @@ print(r_vec)
309
309
  ## [1] 1 2 3 4 5
310
310
  ```
311
311
 
312
- ```r
312
+ ``` r
313
313
  print(reduce_sum(r_vec))
314
314
  ```
315
315
 
@@ -328,7 +328,7 @@ grammar of graphics" [@Wilkinson:grammar_of_graphics]. The idea of the grammar o
328
328
  is to build a graphics by adding layers to the plot. More information can be found in
329
329
  https://towardsdatascience.com/a-comprehensive-guide-to-the-grammar-of-graphics-for-effective-visualization-of-multi-dimensional-1f92b4ed4149.
330
330
 
331
- In the plot bellow the 'mpg' dataset from base R is used. "The data concerns city-cycle fuel
331
+ In the plot below the 'mpg' dataset from base R is used. "The data concerns city-cycle fuel
332
332
  consumption in miles per gallon, to be predicted in terms of 3 multivalued discrete and 5
333
333
  continuous attributes." (Quinlan, 1993)
334
334
 
@@ -342,7 +342,7 @@ car point equal its high way consumption (size = hwy). Finally, a last layer is
342
342
  a linear regression line (method = "lm") for every manufacturer.
343
343
 
344
344
 
345
- ```r
345
+ ``` r
346
346
  # load package and data
347
347
  library(ggplot2)
348
348
  data(mpg, package="ggplot2")
@@ -359,7 +359,11 @@ g + geom_jitter(aes(col=manufacturer, size=hwy)) +
359
359
  geom_smooth(aes(col=manufacturer), method="lm", se=F)
360
360
  ```
361
361
 
362
- ![](/home/rbotafogo/desenv/galaaz/blogs/gknit/gknit_files/figure-html/bubble-1.png)<!-- -->
362
+ ```
363
+ ## `geom_smooth()` using formula = 'y ~ x'
364
+ ```
365
+
366
+ ![](gknit_files/figure-html/bubble-1.png)<!-- -->
363
367
 
364
368
  ### Ruby chunks
365
369
 
@@ -391,7 +395,7 @@ functions. gKnit will knit standard Ruby code, or even general text without
391
395
  any code.
392
396
 
393
397
 
394
- ```ruby
398
+ ``` ruby
395
399
  a = [1, 2, 3]
396
400
  b = "US$ 250.000"
397
401
  c = "The 'outputs' function"
@@ -403,7 +407,7 @@ vec2 = R.c(10, 20, 30)
403
407
  In the next block, variables 'a', 'vec' and 'vec2' are used and printed.
404
408
 
405
409
 
406
- ```ruby
410
+ ``` ruby
407
411
  puts a
408
412
  puts vec * vec2
409
413
  ```
@@ -421,16 +425,16 @@ where multiplication works as expected.
421
425
 
422
426
  ### Accessing R from Ruby
423
427
 
424
- One of the nice aspects of Galaaz on GraalVM, is that variables and functions defined in R, can
428
+ One of the nice aspects of Galaaz 2.0 is that variables and functions defined in R can
425
429
  be easily accessed from Ruby. This next chunk, reads data from R and uses the 'reduce_sum'
426
430
  function defined previously. To access an R variable from Ruby the '~' function should be
427
431
  applied to the Ruby symbol representing the R variable. Since the R variable is called 'r_vec',
428
- in Ruby, the symbol to acess it is ':r_vec' and thus '~:r_vec' retrieves the value of the
432
+ in Ruby, the symbol to acess it is ':r_vec' and thus '~R[:r_vec]' retrieves the value of the
429
433
  variable.
430
434
 
431
435
 
432
- ```ruby
433
- puts ~:r_vec
436
+ ``` ruby
437
+ puts ~R[:r_vec]
434
438
  ```
435
439
 
436
440
  ```
@@ -440,8 +444,8 @@ puts ~:r_vec
440
444
  In order to call an R function, the 'R.' module is used as follows
441
445
 
442
446
 
443
- ```ruby
444
- puts R.reduce_sum(~:r_vec)
447
+ ``` ruby
448
+ puts R.reduce_sum(~R[:r_vec])
445
449
  ```
446
450
 
447
451
  ```
@@ -471,9 +475,9 @@ ten aspects are:
471
475
 
472
476
 
473
477
 
474
- ```ruby
478
+ ``` ruby
475
479
  # copy the R variable :mtcars to the Ruby mtcars variable
476
- mtcars = ~:mtcars
480
+ mtcars = ~R[:mtcars]
477
481
 
478
482
  # create a new column 'car_name' to store the car names so that it can be
479
483
  # used for plotting. The 'rownames' of the data frame cannot be used as
@@ -519,7 +523,7 @@ puts mtcars.head
519
523
  ```
520
524
 
521
525
 
522
- ```ruby
526
+ ``` ruby
523
527
  require 'ggplot'
524
528
 
525
529
  puts mtcars.ggplot(E.aes(x: :car_name, y: :mpg_z, label: :mpg_z)) +
@@ -533,7 +537,7 @@ puts mtcars.ggplot(E.aes(x: :car_name, y: :mpg_z, label: :mpg_z)) +
533
537
  ```
534
538
 
535
539
 
536
- ![](/home/rbotafogo/desenv/galaaz/blogs/gknit/gknit_files/figure-html/diverging_bar.png)<!-- -->
540
+ ![](gknit_files/figure-html/diverging_bar.png)
537
541
 
538
542
  ### Inline Ruby code
539
543
 
@@ -644,24 +648,24 @@ Here, for instance, is a table definition in HTML and its output in the document
644
648
  </div>
645
649
 
646
650
  But manually creating HTML output is not always easy or desirable, specially
647
- if we intend the document to be rendered in other formats, for example, as Latex.
651
+ if we intend the document to be rendered in other formats, for example, as LaTeX.
648
652
  Also, The above
649
653
  table looks ugly. The 'kableExtra' library is a great library for
650
654
  creating beautiful tables. Take a look at https://cran.r-project.org/web/packages/kableExtra/vignettes/awesome_table_in_html.html
651
655
 
652
656
  In the next chunk, we output the 'mtcars' dataframe from R in a nicely formatted
653
- table. Note that we retrieve the mtcars dataframe by using '~:mtcars'.
657
+ table. Note that we retrieve the mtcars dataframe by using '~R[:mtcars]'.
654
658
 
655
659
 
656
- ```ruby
660
+ ``` ruby
657
661
  R.install_and_loads('kableExtra')
658
- outputs (~:mtcars).kable.kable_styling
662
+ outputs (~R[:mtcars]).kable.kable_styling
659
663
  ```
660
664
 
661
665
  <table class="table" style="margin-left: auto; margin-right: auto;">
662
666
  <thead>
663
667
  <tr>
664
- <th style="text-align:left;"> </th>
668
+ <th style="text-align:left;"> </th>
665
669
  <th style="text-align:right;"> mpg </th>
666
670
  <th style="text-align:right;"> cyl </th>
667
671
  <th style="text-align:right;"> disp </th>
@@ -1152,7 +1156,7 @@ true, ruby's 'require\_relative' semantics is used to load the file, when false,
1152
1156
  ```
1153
1157
  ````
1154
1158
 
1155
- Bellow we include file 'model.rb', which is in the same directory of this blog.
1159
+ Below we include file 'model.rb', which is in the same directory of this blog.
1156
1160
  This code uses R 'caret' package to split a dataset in a train and test sets.
1157
1161
  The 'caret' package is a very important a useful package for doing Data Analysis,
1158
1162
  it has hundreds of functions for all steps of the Data Analysis workflow. To
@@ -1170,7 +1174,7 @@ will install the package if it is not already installed and can take a while.
1170
1174
  ````
1171
1175
 
1172
1176
 
1173
- ```include
1177
+ ``` include
1174
1178
  require 'galaaz'
1175
1179
 
1176
1180
  # Loads the R 'caret' package. If not present, installs it
@@ -1202,7 +1206,7 @@ class Model
1202
1206
  def partition(field)
1203
1207
 
1204
1208
  train_index =
1205
- R.createDataPartition(@data.send(field), p: @percet_train,
1209
+ R.createDataPartition(@data.send(field), p: @percent_train,
1206
1210
  list: false, times: 1)
1207
1211
  @train = @data[train_index, :all]
1208
1212
  @test = @data[-train_index, :all]
@@ -1210,12 +1214,11 @@ class Model
1210
1214
  end
1211
1215
 
1212
1216
  end
1213
-
1214
1217
  ```
1215
1218
 
1216
1219
 
1217
- ```ruby
1218
- mtcars = ~:mtcars
1220
+ ``` ruby
1221
+ mtcars = ~R[:mtcars]
1219
1222
  model = Model.new(mtcars, percent_train: 0.8)
1220
1223
  model.partition(:mpg)
1221
1224
  puts model.train.head
@@ -1224,19 +1227,17 @@ puts model.test.head
1224
1227
 
1225
1228
  ```
1226
1229
  ## mpg cyl disp hp drat wt qsec vs am gear carb
1230
+ ## Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4
1227
1231
  ## Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1
1228
1232
  ## Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1
1229
1233
  ## Hornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2
1234
+ ## Valiant 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1
1230
1235
  ## Merc 240D 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2
1231
- ## Merc 280 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4
1232
- ## Merc 280C 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4
1233
- ## mpg cyl disp hp drat wt qsec vs am gear carb
1234
- ## Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4
1235
- ## Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4
1236
- ## Valiant 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1
1237
- ## Duster 360 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4
1238
- ## Merc 230 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2
1239
- ## Merc 450SE 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3
1236
+ ## mpg cyl disp hp drat wt qsec vs am gear carb
1237
+ ## Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4
1238
+ ## Duster 360 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4
1239
+ ## Toyota Corolla 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1
1240
+ ## Ford Pantera L 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4
1240
1241
  ```
1241
1242
 
1242
1243
  ### Documenting Gems
@@ -1244,9 +1245,9 @@ puts model.test.head
1244
1245
  gKnit also allows developers to document and load files that are not in the same directory
1245
1246
  of the '.Rmd' file.
1246
1247
 
1247
- Here is an example of loading the 'find.rb' file from TruffleRuby. In this example, relative
1248
+ Here is an example of loading the 'find.rb' file from **JRuby** (via `$LOAD_PATH`). In this example, relative
1248
1249
  is set to FALSE, so Ruby will look for the file in its $LOAD\_PATH, and the user does not
1249
- need to no it's directory.
1250
+ need to know its directory.
1250
1251
 
1251
1252
  ````
1252
1253
  ```{include find, relative = FALSE}
@@ -1254,7 +1255,7 @@ need to no it's directory.
1254
1255
  ````
1255
1256
 
1256
1257
 
1257
- ```include
1258
+ ``` include
1258
1259
  # frozen_string_literal: true
1259
1260
  #
1260
1261
  # find.rb: the Find module for processing all files under a given directory.
@@ -1272,7 +1273,7 @@ need to no it's directory.
1272
1273
  #
1273
1274
  # Find.find(ENV["HOME"]) do |path|
1274
1275
  # if FileTest.directory?(path)
1275
- # if File.basename(path)[0] == ?.
1276
+ # if File.basename(path).start_with?('.')
1276
1277
  # Find.prune # Don't look any further into this directory.
1277
1278
  # else
1278
1279
  # next
@@ -1284,6 +1285,8 @@ need to no it's directory.
1284
1285
  #
1285
1286
  module Find
1286
1287
 
1288
+ VERSION = "0.2.0"
1289
+
1287
1290
  #
1288
1291
  # Calls the associated block with the name of every file and directory listed
1289
1292
  # as arguments, then recursively on their subdirectories, and so on.
@@ -1303,24 +1306,24 @@ module Find
1303
1306
  ps = [path]
1304
1307
  while file = ps.shift
1305
1308
  catch(:prune) do
1306
- yield file.dup.taint
1309
+ yield file.dup
1307
1310
  begin
1308
1311
  s = File.lstat(file)
1309
- rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG
1312
+ rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG, Errno::EINVAL
1310
1313
  raise unless ignore_error
1311
1314
  next
1312
1315
  end
1313
1316
  if s.directory? then
1314
1317
  begin
1315
1318
  fs = Dir.children(file, encoding: enc)
1316
- rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG
1319
+ rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG, Errno::EINVAL
1317
1320
  raise unless ignore_error
1318
1321
  next
1319
1322
  end
1320
1323
  fs.sort!
1321
1324
  fs.reverse_each {|f|
1322
1325
  f = File.join(file, f)
1323
- ps.unshift f.untaint
1326
+ ps.unshift f
1324
1327
  }
1325
1328
  end
1326
1329
  end
@@ -1333,7 +1336,7 @@ module Find
1333
1336
  # Skips the current file or directory, restarting the loop with the next
1334
1337
  # entry. If the current file is a directory, that directory will not be
1335
1338
  # recursively entered. Meaningful only within the block associated with
1336
- # Find::find.
1339
+ # Find:R[:find].
1337
1340
  #
1338
1341
  # See the +Find+ module documentation for an example.
1339
1342
  #
@@ -1357,9 +1360,9 @@ the Yaml header to generate this blog in PDF format instead of HTML:
1357
1360
 
1358
1361
  ```
1359
1362
  ---
1360
- title: "gKnit - Ruby and R Knitting with Galaaz in GraalVM"
1363
+ title: "gKnit - Ruby and R Knitting with Galaaz (JRuby + GNU R)"
1361
1364
  author: "Rodrigo Botafogo"
1362
- tags: [Galaaz, Ruby, R, TruffleRuby, FastR, GraalVM, knitr, gknit]
1365
+ tags: [Galaaz, Ruby, R, JRuby, "GNU R", knitr, gknit]
1363
1366
  date: "29 October 2018"
1364
1367
  output:
1365
1368
  pdf\_document:
@@ -1372,27 +1375,23 @@ output:
1372
1375
 
1373
1376
  # Conclusion
1374
1377
 
1375
- In order to do reproducible research, one of the main basic tools needed is a systhem that
1378
+ In order to do reproducible research, one of the main basic tools needed is a system that
1376
1379
  allows "literate programming" where text, code and possibly a set of files can be compiled
1377
1380
  onto a report that can be easily distributed to peers. Peers should be able to use this
1378
1381
  same set of files to rerun the compilation by their own obtaining the exact same original
1379
1382
  report. gKnit is such a system for Ruby and R. It uses __R Markdown__ to integrate
1380
- text and code chunks, where code chunks can either be part of the __R Markdwon__ file or
1383
+ text and code chunks, where code chunks can either be part of the __R Markdown__ file or
1381
1384
  be imported from files in the system. Ideally, in reproducible research, all the files
1382
- needed to rebuild a report should be easilly packed together (in the same zipped directory)
1385
+ needed to rebuild a report should be easily packed together (in the same zipped directory)
1383
1386
  and distributed to peers for reexecution.
1384
1387
 
1385
- One of the promises of Oracle's GraalVM is that users/developers will be able to use the best tool
1386
- for their task at hand, independently of the programming language the tool was written on.
1387
- We developed and implemented Galaaz atop the GraalVM and Truffle interop messages and
1388
- the time and effort to wrap Ruby over R - Galaaz - or to
1389
- wrap Knitr with gKnit was a fraction of a fraction of a fraction (one man effort for a couple
1390
- of hours a day, for approximately six months) of the time require to
1391
- implement the original tools. Trying to reimplement all R packages in Ruby would require the
1392
- same effort it is taking Python to implement NumPy, Pandas and all supporting libraries and it
1393
- is unlikely that this effort would ever be done. GraalVM has allowed Ruby to profit "almost
1394
- for free" from this huge set of libraries and tools that make R one of the most used
1395
- languages for data analysis and machine learning.
1388
+ **Galaaz 2.0** pairs **JRuby** with **GNU R**: you keep the full CRAN/Bioconductor world in R while
1389
+ writing orchestration, reuse, and application code in Ruby. The effort to wrap Ruby over R (Galaaz)
1390
+ and to wrap Knitr as gKnit was tiny compared to reimplementing R’s ecosystem in Ruby—much like
1391
+ Python’s investment in NumPy and Pandas, which no Ruby project is likely to duplicate.
1392
+
1393
+ An **earlier** prototype used Oracle’s **GraalVM** and Truffle interop; the **current** stack is
1394
+ deliberately **standard GNU R** plus the Galaaz **bridge**, documented in the project manual.
1396
1395
 
1397
1396
  More interesting than wrapping the R libraries with Ruby, is that Ruby adds
1398
1397
  value to R, by allowing developers to use powerful and modern constructs for code reuse that
@@ -1402,11 +1401,10 @@ readability.
1402
1401
 
1403
1402
  # Installing gKnit
1404
1403
 
1405
- ## Prerequisites
1404
+ ## Prerequisites (Galaaz 2.0)
1406
1405
 
1407
- * GraalVM (>= rc8)
1408
- * TruffleRuby
1409
- * FastR
1406
+ * **JRuby** and a compatible **JDK**
1407
+ * **GNU R** on your `PATH`
1410
1408
 
1411
1409
  The following R packages will be automatically installed when necessary, but could be installed prior
1412
1410
  to using gKnit if desired:
@@ -1415,16 +1413,18 @@ to using gKnit if desired:
1415
1413
  * gridExtra
1416
1414
  * knitr
1417
1415
 
1418
- Installation of R packages requires a development environment and can be time consuming. In Linux,
1419
- the gnu compiler and tools should be enough. I am not sure what is needed on the Mac.
1416
+ Installation of R packages requires a development environment and can be time consuming. On Linux,
1417
+ the usual build tools are typically enough. On macOS, Xcode command-line tools are commonly required.
1420
1418
 
1421
1419
  ## Preparation
1422
1420
 
1423
- * gem install galaaz
1421
+ * Install the **galaaz** gem (RubyGems or a local build / `path:`).
1424
1422
 
1425
1423
  ## Usage
1426
1424
 
1427
- * gknit \<filename\>
1425
+ * **`bin/gknit`** \<filename\> (from the Galaaz repo or your install layout); use **`--output_format all`** for HTML and PDF together.
1426
+ * Run Ruby with **`bin/galaaz-jruby`** when you need the same JVM flags as the project (see the manual).
1427
+
1428
1428
 
1429
1429
  # References
1430
1430
 
data/blogs/gknit/lst.rds CHANGED
Binary file
data/blogs/gknit/model.rb CHANGED
@@ -29,7 +29,7 @@ class Model
29
29
  def partition(field)
30
30
 
31
31
  train_index =
32
- R.createDataPartition(@data.send(field), p: @percet_train,
32
+ R.createDataPartition(@data.send(field), p: @percent_train,
33
33
  list: false, times: 1)
34
34
  @train = @data[train_index, :all]
35
35
  @test = @data[-train_index, :all]
File without changes
@@ -0,0 +1,14 @@
1
+ ---
2
+ title: "include model local repro"
3
+ output:
4
+ github_document: default
5
+ ---
6
+
7
+ ```{include model}
8
+ ```
9
+
10
+ ```{ruby, echo=FALSE}
11
+ mtcars = ~R[:mtcars]
12
+ model = Model.new(mtcars, percent_train: 0.8)
13
+ puts model.class
14
+ ```
@@ -0,0 +1,75 @@
1
+ include model local repro
2
+ ================
3
+
4
+ ``` include
5
+ require 'galaaz'
6
+
7
+ # Loads the R 'caret' package. If not present, installs it
8
+ R.install_and_loads 'caret'
9
+
10
+ class Model
11
+
12
+ attr_reader :data
13
+ attr_reader :test
14
+ attr_reader :train
15
+
16
+ #==========================================================
17
+ #
18
+ #==========================================================
19
+
20
+ def initialize(data, percent_train:, seed: 123)
21
+
22
+ R.set__seed(seed)
23
+ @data = data
24
+ @percent_train = percent_train
25
+ @seed = seed
26
+
27
+ end
28
+
29
+ #==========================================================
30
+ #
31
+ #==========================================================
32
+
33
+ def partition(field)
34
+
35
+ train_index =
36
+ R.createDataPartition(@data.send(field), p: @percet_train,
37
+ list: false, times: 1)
38
+ @train = @data[train_index, :all]
39
+ @test = @data[-train_index, :all]
40
+
41
+ end
42
+
43
+ end
44
+ ```
45
+
46
+ ## Failed to install packages: [1] "caret". Check stderr output above for [RUBY] debug messages.
47
+
48
+ ## /home/rbotafogo/desenv_linux/galaaz/lib/R_interface/r.rb:143:in 'install_rlibs'
49
+ ## /home/rbotafogo/desenv_linux/galaaz/lib/R_interface/r.rb:154:in 'install_and_loads'
50
+ ## /home/rbotafogo/desenv_linux/galaaz/lib/util/exec_ruby.rb:173:in 'exec_ruby'
51
+ ## org/jruby/RubyKernel.java:1268:in 'eval'
52
+ ## /home/rbotafogo/desenv_linux/galaaz/lib/util/exec_ruby.rb:169:in 'exec_ruby'
53
+ ## /home/rbotafogo/desenv_linux/galaaz/lib/gknit/knitr_engine.rb:770:in 'block in initialize'
54
+ ## org/jruby/RubyBasicObject.java:2695:in 'instance_eval'
55
+ ## org/jruby/RubyBasicObject.java:2723:in 'instance_eval'
56
+ ## /home/rbotafogo/desenv_linux/galaaz/lib/gknit/knitr_engine.rb:741:in 'block in initialize'
57
+ ## /home/rbotafogo/desenv_linux/galaaz/lib/gknit/include_engine.rb:54:in 'block in initialize'
58
+ ## /home/rbotafogo/desenv_linux/galaaz/lib/R_interface/new_bridge_adapter.rb:233:in 'block in register_callback_proc_stub'
59
+ ## /home/rbotafogo/desenv_linux/galaaz/lib/new_bridge/session_client.rb:344:in 'block in handle_call'
60
+
61
+ uninitialized constant RC::Modelorg/jruby/RubyModule.java:4875:in
62
+ ‘const_missing’
63
+ /home/rbotafogo/desenv_linux/galaaz/lib/util/exec_ruby.rb:171:in
64
+ ‘exec_ruby’ org/jruby/RubyKernel.java:1268:in ‘eval’
65
+ /home/rbotafogo/desenv_linux/galaaz/lib/util/exec_ruby.rb:169:in
66
+ ‘exec_ruby’
67
+ /home/rbotafogo/desenv_linux/galaaz/lib/gknit/knitr_engine.rb:770:in
68
+ ‘block in initialize’ org/jruby/RubyBasicObject.java:2695:in
69
+ ‘instance_eval’ org/jruby/RubyBasicObject.java:2723:in ‘instance_eval’
70
+ /home/rbotafogo/desenv_linux/galaaz/lib/gknit/knitr_engine.rb:741:in
71
+ ‘block in initialize’
72
+ /home/rbotafogo/desenv_linux/galaaz/lib/R_interface/new_bridge_adapter.rb:233:in
73
+ ‘block in register_callback_proc_stub’
74
+ /home/rbotafogo/desenv_linux/galaaz/lib/new_bridge/session_client.rb:344:in
75
+ ‘block in handle_call’
Binary file