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
@@ -0,0 +1,364 @@
1
+ # Introduction
2
+
3
+ Galaaz is a system for tightly coupling Ruby and R. Ruby is a powerful
4
+ language, with a large community, a very large set of libraries and
5
+ great for web development. However, it lacks libraries for data science,
6
+ statistics, scientific plotting and machine learning. On the other hand,
7
+ R is considered one of the most powerful languages for solving all of
8
+ the above problems. Maybe the strongest competitor to R is Python with
9
+ libraries such as NumPy, Panda, SciPy, SciKit-Learn and a couple more.
10
+
11
+ With Galaaz we do not intend to re-implement any of the scientific
12
+ libraries in R; we allow for very tight coupling between the two
13
+ languages to the point that the Ruby developer does not need to think
14
+ about R syntax for every call. **Galaaz 2.0** does this with
15
+ **[JRuby](https://www.jruby.org/)** and **GNU R**: a **bridge**
16
+ evaluates R from Ruby and exchanges data between processes.
17
+
18
+ An **earlier** Galaaz prototype used Oracle’s **GraalVM** with
19
+ **TruffleRuby** and **FastR** in one JVM. That stack is **historical**;
20
+ today’s documentation and tooling assume **JRuby + GNU R** (see the
21
+ project manual and **`bin/galaaz-jruby`** / **`bin/gknit`**).
22
+
23
+ For background on the old stack:
24
+
25
+ - [GraalVM Home](https://www.graalvm.org/)
26
+ - [TruffleRuby](https://github.com/oracle/truffleruby)
27
+ - [FastR](https://github.com/oracle/fastr)
28
+ - [Faster R with
29
+ FastR](https://medium.com/graalvm/faster-r-with-fastr-4b8db0e0dceb)
30
+
31
+ ## What does Galaaz mean
32
+
33
+ Galaaz is the Portuguese name for “Galahad”. From Wikipedia:
34
+
35
+ Sir Galahad (sometimes referred to as Galeas or Galath),
36
+ in Arthurian legend, is a knight of King Arthur's Round Table and one
37
+ of the three achievers of the Holy Grail. He is the illegitimate son
38
+ of Sir Lancelot and Elaine of Corbenic, and is renowned for his
39
+ gallantry and purity as the most perfect of all knights. Emerging quite
40
+ late in the medieval Arthurian tradition, Sir Galahad first appears in the
41
+ Lancelot–Grail cycle, and his story is taken up in later works such as
42
+ the Post-Vulgate Cycle and Sir Thomas Malory's Le Morte d'Arthur.
43
+ His name should not be mistaken with Galehaut, a different knight from
44
+ Arthurian legend.
45
+
46
+ # Galaaz Demo
47
+
48
+ ## Prerequisites (Galaaz 2.0)
49
+
50
+ - **JRuby** and a compatible **JDK**
51
+ - **GNU R** on your `PATH`
52
+
53
+ The following R packages will be automatically installed when necessary,
54
+ but could be installed prior to the demo if desired:
55
+
56
+ - ggplot2
57
+ - gridExtra
58
+
59
+ Installation of R packages requires a development environment. In Linux,
60
+ the gnu compiler and tools should be enough. I am not sure what is
61
+ needed on the Mac.
62
+
63
+ In order to run the ‘specs’ the following Ruby package is necessary:
64
+
65
+ - gem install rspec
66
+
67
+ ## Preparation
68
+
69
+ - gem install galaaz
70
+
71
+ ## Running the demo
72
+
73
+ The ggplot for this demos was extracted from:
74
+ <http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html>.
75
+
76
+ On the console do
77
+
78
+ > galaaz master_list:scatter_plot
79
+
80
+ ## Running other demos
81
+
82
+ Doing on the console
83
+
84
+ > galaaz -T
85
+
86
+ will show a list with all available demos. To run any of the demos in
87
+ the list, substitute the call to ‘rake’ to ‘galaaz’. For instance, one
88
+ of the examples in the list is ‘rake sthda:bar’. In order to run this
89
+ example just do ‘galaaz sthda:bar’. Doing ‘galaaz sthda:all’ will run
90
+ all demos in the sthda cathegory. Some of the examples require ‘rspec’
91
+ do be available. To install ‘rspec’ just do ‘gem install rspec’.
92
+
93
+ # The demo code
94
+
95
+ The following is the Ruby code and plot for the above example. There is
96
+ a small difference between the code in the example and the code bellow.
97
+ If the example is ran, the plot will appear on the screen, bellow, we
98
+ generate an ‘svg’ image and then include it in this document. In order
99
+ to generate and image, the R.svg device is used. To generate the plot on
100
+ the screen, use the R.awt device, as commented on the code.
101
+
102
+ ``` ruby
103
+ require 'galaaz'
104
+ require 'ggplot'
105
+
106
+ # load package and data
107
+ R.options(scipen: 999) # turn-off scientific notation like 1e+48
108
+ R.theme_set(R.theme_bw) # pre-set the bw theme.
109
+
110
+ midwest = ~R[:midwest]
111
+
112
+ # Scatterplot
113
+ gg = midwest.ggplot(E.aes(x: :area, y: :poptotal)) +
114
+ R.geom_point(E.aes(col: :state, size: :popdensity)) +
115
+ R.geom_smooth(method: "loess", se: false) +
116
+ R.xlim(R.c(0, 0.1)) +
117
+ R.ylim(R.c(0, 500000)) +
118
+ R.labs(subtitle: "Area Vs Population",
119
+ y: "Population",
120
+ x: "Area",
121
+ title: "Scatterplot",
122
+ caption: "Source: midwest")
123
+
124
+ puts gg
125
+ ```
126
+
127
+ ![](galaaz_ggplot_files/figure-markdown_github/midwest_rb.png)
128
+
129
+ In R, the code to generate this plot is the following
130
+
131
+ ``` r
132
+ # install.packages("ggplot2")
133
+ # load package and data
134
+ options(scipen=999) # turn-off scientific notation like 1e+48
135
+ library(ggplot2)
136
+ theme_set(theme_bw()) # pre-set the bw theme.
137
+ data("midwest", package = "ggplot2")
138
+ # midwest <- read.csv("http://goo.gl/G1K41K") # bkup data source
139
+
140
+ # Scatterplot
141
+ gg <- ggplot(midwest, aes(x=area, y=poptotal)) +
142
+ geom_point(aes(col=state, size=popdensity)) +
143
+ geom_smooth(method="loess", se=F) +
144
+ xlim(c(0, 0.1)) +
145
+ ylim(c(0, 500000)) +
146
+ labs(subtitle="Area Vs Population",
147
+ y="Population",
148
+ x="Area",
149
+ title="Scatterplot",
150
+ caption = "Source: midwest")
151
+
152
+ plot(gg)
153
+ ```
154
+
155
+ Note that both codes are very similar. The Ruby code requires the use of
156
+ “R.” before calling any functions, for instance R function ‘geom_point’
157
+ becomes ‘R.geom_point’ in Ruby. R named parameters such as (col = state,
158
+ size = popdensity), become in Ruby (col: :state, size: :popdensity).
159
+
160
+ One last point that needs to be observed is the call to the ‘aes’
161
+ function. In Ruby instead of doing ‘R.aes’, we use ‘E.aes’. The
162
+ explanation of why E.aes is needed is an advanced topic in R and depends
163
+ on what is know as Non-standard Evaluation (NSE) in R. In short,
164
+ function ‘aes’ is lazily evaluated in R, i.e., in R when calling
165
+ geom_point(aes(col=state, size=popdensity)), function geom_point
166
+ receives as argument something similar to a string containing
167
+ ‘aes(col=state, size=popdensity)’, and the aes function will be
168
+ evaluated inside the geom_point function. In Ruby, there is no Lazy
169
+ evaluation and doing R.aes would try to evaluate aes immediately. In
170
+ order to delay the evaluation of function aes we need to use E.aes. The
171
+ interested reader on NSE in R is directed to
172
+ <http://adv-r.had.co.nz/Computing-on-the-language.html>.
173
+
174
+ # An extension to the example
175
+
176
+ If both codes are so similar, then why would one use Ruby instead of R
177
+ and what good is galaaz after all?
178
+
179
+ Ruby is a modern OO language with numerous very useful constructs such
180
+ as classes, modules, blocks, procs, etc. The example above focus on the
181
+ coupling of both languages, and does not show the use of other Ruby
182
+ constructs. In the following example, we will show a more complex
183
+ example using other Ruby constructs. This is certainly not a very well
184
+ written and robust Ruby code, but it give the idea of how Ruby and R are
185
+ strongly coupled.
186
+
187
+ Let’s imagine that we work in a corporation that has its plot themes.
188
+ So, it has defined a ‘CorpTheme’ module. Plots in this corporation
189
+ should not have grids, numbers in labels should not use scientific
190
+ notation and the preferred color is blue.
191
+
192
+ ``` ruby
193
+ # corp_theme.rb
194
+ # defines the corporate theme for all plots
195
+
196
+ module CorpTheme
197
+
198
+ #---------------------------------------------------------------------------------
199
+ # Defines the plot theme (visualization). In this theme we remove major and minor
200
+ # grids, borders and background. We also turn-off scientific notation.
201
+ #---------------------------------------------------------------------------------
202
+
203
+ def self.global_theme
204
+
205
+ R.options(scipen: 999) # turn-off scientific notation like 1e+48
206
+
207
+ # remove major grids
208
+ global_theme = R.theme(panel__grid__major: E.element_blank())
209
+ # remove minor grids
210
+ global_theme = global_theme + R.theme(panel__grid__minor: E.element_blank)
211
+ # remove border
212
+ global_theme = global_theme + R.theme(panel__border: E.element_blank)
213
+ # remove background
214
+ global_theme = global_theme + R.theme(panel__background: E.element_blank)
215
+ # Change axis font
216
+ global_theme = global_theme +
217
+ R.theme(axis__text: E.element_text(size: 8, color: "#000080"))
218
+ # change color of axis titles
219
+ global_theme = global_theme +
220
+ R.theme(axis__title: E.element_text(
221
+ color: "#000080",
222
+ face: "bold",
223
+ size: 8,
224
+ hjust: 1))
225
+ end
226
+
227
+ end
228
+ ```
229
+
230
+ We now define a ScatterPlot class:
231
+
232
+ ``` ruby
233
+ # ScatterPlot.rb
234
+ # creates a scatter plot and allow some configuration
235
+
236
+ class ScatterPlot
237
+
238
+ attr_accessor :title
239
+ attr_accessor :subtitle
240
+ attr_accessor :caption
241
+ attr_accessor :x_label
242
+ attr_accessor :y_label
243
+
244
+ #---------------------------------------------------------------------------------
245
+ # Initialize the plot with the data and the x and y variables
246
+ #---------------------------------------------------------------------------------
247
+
248
+ def initialize(data, x:, y:)
249
+ @data = data
250
+ @x = x
251
+ @y = y
252
+ end
253
+
254
+ #---------------------------------------------------------------------------------
255
+ # Define groupings by color and size
256
+ #---------------------------------------------------------------------------------
257
+
258
+ def group_by(color:, size:)
259
+ @color_by = color
260
+ @size_by = size
261
+ end
262
+
263
+ #---------------------------------------------------------------------------------
264
+ # Add a smoothing line, and if confidence is true the add a confidence interval, if
265
+ # false does not add the confidence interval
266
+ #---------------------------------------------------------------------------------
267
+
268
+ def add_smoothing_line(method:, confidence: true)
269
+ @method = method
270
+ @confidence = confidence
271
+ end
272
+
273
+ #---------------------------------------------------------------------------------
274
+ # Creates the graph title, properly formated for this theme
275
+ # @param title [String] The title to add to the graph
276
+ # @return textGrob that can be included in a graph
277
+ #---------------------------------------------------------------------------------
278
+
279
+ def graph_params(title: "", subtitle: "", caption: "", x_label: "", y_label: "")
280
+ R.labs(
281
+ title: title,
282
+ subtitle: subtitle,
283
+ caption: caption,
284
+ y_label: y_label,
285
+ x_label: x_label,
286
+ )
287
+ end
288
+
289
+ #---------------------------------------------------------------------------------
290
+ # Prepare the plot's points
291
+ #---------------------------------------------------------------------------------
292
+
293
+ def points
294
+ params = {}
295
+ params[:col] = @color_by if @color_by
296
+ params[:size] = @size_by if @size_by
297
+ R.geom_point(E.aes(params))
298
+ end
299
+
300
+ #---------------------------------------------------------------------------------
301
+ # Plots the scatterplot
302
+ #---------------------------------------------------------------------------------
303
+
304
+ def plot
305
+ gg = @data.ggplot(E.aes(x: @x, y: @y)) +
306
+ points +
307
+ R.geom_smooth(method: @method, se: @confidence) +
308
+ R.xlim(R.c(0, 0.1)) +
309
+ R.ylim(R.c(0, 500000)) +
310
+ graph_params(title: @title,
311
+ subtitle: @subtitle,
312
+ y_label: @y_label,
313
+ x_label: @x_label,
314
+ caption: @caption) +
315
+ CorpTheme.global_theme
316
+
317
+ puts gg
318
+
319
+ end
320
+
321
+ end
322
+ ```
323
+
324
+ And this is the final code for making the scatter plot with the midwest
325
+ data
326
+
327
+ ``` ruby
328
+ require 'galaaz'
329
+ require 'ggplot'
330
+
331
+ sp = ScatterPlot.new(~R[:midwest], x: :area, y: :poptotal)
332
+ sp.title = "Midwest Dataset - Scatterplot"
333
+ sp.subtitle = "Area Vs Population"
334
+ sp.caption = "Source: midwest"
335
+ sp.x_label = "Area"
336
+ sp.y_label = "Population"
337
+ sp.group_by(color: :state, size: :popdensity) # try sp.group_by(color: :state)
338
+ # available methods: "lm", "glm", "loess", "gam"
339
+ sp.add_smoothing_line(method: "glm")
340
+ sp.plot
341
+ ```
342
+
343
+ ![](galaaz_ggplot_files/figure-markdown_github/scatter_plot_rb.png)
344
+
345
+ # Conclusion
346
+
347
+ R is a very powerful language for statistical analysis, data analytics,
348
+ machine learning, plotting and many other scientific applications with a
349
+ very large package ecosystem. However R is often considered hard to
350
+ learn and lacking modern computer languages constructs such as object
351
+ oriented classes, modules, lambdas, etc. For this reason, many
352
+ developers have started or switched from R to Python.
353
+
354
+ With Galaaz, R programmers can almost transparently migrate from R to
355
+ Ruby, since syntax is almost identical and **GNU R** remains the engine
356
+ for statistics and **ggplot2**. Further, by using Galaaz the R developer
357
+ can start (slowly if needed) using Ruby’s constructs and libraries that
358
+ nicely complement R packages.
359
+
360
+ For the Ruby developer, Galaaz allows the immediate use of R functions
361
+ with minimal ceremony. As shown in the second example above, class
362
+ `ScatterPlot` hides most R call details from the Ruby developer.
363
+ **JRuby** provides **real parallel threads** on the Ruby side and access
364
+ to the JVM ecosystem when you need it.