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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/LICENSE +0 -0
- data/README.md +3123 -882
- data/Rakefile +62 -41
- data/bin/galaaz-bootstrap +137 -0
- data/bin/galaaz-jruby +14 -0
- data/bin/galaaz_jruby_env.inc.sh +6 -0
- data/bin/gbookdown +64 -0
- data/bin/gknit +223 -6
- data/bin/gknit-draft +105 -0
- data/bin/gknit-draft.rb +28 -0
- data/bin/gknit_Rscript +127 -0
- data/bin/grun +27 -1
- data/bin/gstudio +49 -4
- data/bin/{gstudio.rb → gstudio_irb.rb} +0 -0
- data/bin/gstudio_pry.rb +7 -0
- data/bin/install-tinytex +6 -0
- data/bin/run_all_rspec +43 -0
- data/bin/run_example +14 -0
- data/bin/run_old_rspec +19 -0
- data/bin/run_rspec +23 -0
- data/bin/run_rspec_subset +38 -0
- data/bin/run_slow_rspec +19 -0
- data/blogs/R-on-Rails-Planning-Document.md +940 -0
- data/blogs/README.md +100 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +38 -66
- data/blogs/galaaz_ggplot/galaaz_ggplot.log +754 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.md +364 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.tex +607 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/midwest_rb.png +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/scatter_plot_rb.png +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/midwest_rb.png +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/scatter_plot_rb.png +0 -0
- data/blogs/galaaz_ggplot/midwest.Rmd +3 -3
- data/blogs/galaaz_ggplot/midwest_external_png +0 -0
- data/blogs/gknit/gknit.Rmd +52 -55
- data/blogs/gknit/gknit.md +94 -94
- data/blogs/gknit/gknit_files/figure-html/bubble-1.png +0 -0
- data/blogs/gknit/gknit_files/figure-html/diverging_bar.png +0 -0
- data/blogs/gknit/lst.rds +0 -0
- data/blogs/gknit/model.rb +1 -1
- data/blogs/gknit/stats.bib +0 -0
- data/blogs/manual/include_model_local_repro.Rmd +14 -0
- data/blogs/manual/include_model_local_repro.md +75 -0
- data/blogs/manual/lst.rds +0 -0
- data/blogs/manual/manual.Rmd +1582 -196
- data/blogs/manual/manual.log +1786 -0
- data/blogs/manual/manual.md +3107 -890
- data/blogs/manual/manual.tex +3018 -1086
- data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
- data/blogs/manual/manual_files/figure-html/diverging_bar.png +0 -0
- data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
- data/blogs/manual/model.rb +41 -0
- data/blogs/nse_dplyr/nse_dplyr.Rmd +277 -151
- data/blogs/nse_dplyr/nse_dplyr.log +928 -0
- data/blogs/nse_dplyr/nse_dplyr.md +457 -293
- data/blogs/oh_my/not_so.rb +0 -0
- data/blogs/oh_my/oh_my.Rmd +1234 -25
- data/blogs/oh_my/oh_my.log +804 -0
- data/blogs/oh_my/oh_my.md +1808 -228
- data/blogs/oh_my/oh_my.tex +821 -0
- data/blogs/oh_my/old.Rmd +15 -14
- data/blogs/ruby_plot/ruby_plot.Rmd +58 -82
- data/blogs/ruby_plot/ruby_plot.log +885 -0
- data/blogs/ruby_plot/ruby_plot.md +71 -103
- data/blogs/ruby_plot/ruby_plot.tex +940 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/dose_len.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
- data/blogs/test/test.Rmd +14 -0
- data/examples/50Plots_MasterList/Images/midwest-scatterplot.PNG +0 -0
- data/examples/50Plots_MasterList/ScatterPlot.rb +0 -0
- data/examples/50Plots_MasterList/scatter_plot.rb +0 -0
- data/examples/Bibliography/master.bib +50 -0
- data/examples/Bibliography/stats.bib +72 -0
- data/examples/R/calc.R +0 -0
- data/examples/R/java_interop.R +0 -0
- data/examples/bioconductor_deseq2_airway/Documentation/DESeq2-airway-walkthrough.md +56 -0
- data/examples/bioconductor_deseq2_airway/bench_galaaz_three_same_process.rb +53 -0
- data/examples/bioconductor_deseq2_airway/bench_r_three_same_process.R +34 -0
- data/examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb +33 -0
- data/examples/bioconductor_deseq2_airway/deseq2_airway_galaaz_optimized.rb +34 -0
- data/examples/bioconductor_deseq2_airway/deseq2_airway_minimal.R +30 -0
- data/examples/bioconductor_deseq2_airway/deseq2_airway_pipeline_for_bench.R +36 -0
- data/examples/islr/all.rb +13 -0
- data/examples/islr/ch2.spec.rb +37 -7
- data/examples/islr/ch3.spec.rb +11 -2
- data/examples/islr/ch3_boston.rb +27 -0
- data/examples/islr/ch3_multiple_regression.rb +0 -0
- data/examples/islr/ch6.spec.rb +24 -1
- data/examples/islr/x_y_rnorm.jpg +0 -0
- data/examples/latex_templates/Test-acm_article/Makefile +16 -0
- data/examples/latex_templates/Test-acm_article/Test-acm_article.Rmd +65 -0
- data/examples/latex_templates/Test-acm_article/acm_proc_article-sp.cls +1670 -0
- data/examples/latex_templates/Test-acm_article/sensys-abstract.cls +703 -0
- data/examples/latex_templates/Test-acm_article/sigproc.bib +59 -0
- data/examples/latex_templates/Test-acs_article/Test-acs_article.Rmd +260 -0
- data/examples/latex_templates/Test-acs_article/acs-Test-acs_article.bib +11 -0
- data/examples/latex_templates/Test-acs_article/acs-my_output.bib +11 -0
- data/examples/latex_templates/Test-acs_article/acstest.bib +17 -0
- data/examples/latex_templates/Test-aea_article/AEA.cls +1414 -0
- data/{blogs/gknit/marshal.dump → examples/latex_templates/Test-aea_article/BibFile.bib} +0 -0
- data/examples/latex_templates/Test-aea_article/Test-aea_article.Rmd +108 -0
- data/examples/latex_templates/Test-aea_article/aea.bst +1269 -0
- data/examples/latex_templates/Test-aea_article/multicol.sty +853 -0
- data/examples/latex_templates/Test-aea_article/references.bib +0 -0
- data/examples/latex_templates/Test-aea_article/setspace.sty +546 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.Rmd +256 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.pdfsync +3397 -0
- data/examples/latex_templates/Test-ams_article/Test-ams_article.Rmd +215 -0
- data/examples/latex_templates/Test-ams_article/amstest.bib +436 -0
- data/examples/latex_templates/Test-asa_article/Test-asa_article.Rmd +153 -0
- data/examples/latex_templates/Test-asa_article/agsm.bst +1353 -0
- data/examples/latex_templates/Test-asa_article/bibliography.bib +233 -0
- data/examples/latex_templates/Test-ieee_article/IEEEtran.bst +2409 -0
- data/examples/latex_templates/Test-ieee_article/IEEEtran.cls +6346 -0
- data/examples/latex_templates/Test-ieee_article/Test-ieee_article.Rmd +175 -0
- data/examples/latex_templates/Test-ieee_article/mybibfile.bib +20 -0
- data/examples/latex_templates/Test-rjournal_article/RJournal.sty +335 -0
- data/examples/latex_templates/Test-rjournal_article/RJreferences.bib +18 -0
- data/examples/latex_templates/Test-rjournal_article/Test-rjournal_article.Rmd +52 -0
- data/examples/latex_templates/Test-springer_article/Test-springer_article.Rmd +65 -0
- data/examples/latex_templates/Test-springer_article/bibliography.bib +26 -0
- data/examples/latex_templates/Test-springer_article/spbasic.bst +1658 -0
- data/examples/latex_templates/Test-springer_article/spmpsci.bst +1512 -0
- data/examples/latex_templates/Test-springer_article/spphys.bst +1443 -0
- data/examples/latex_templates/Test-springer_article/svglov3.clo +113 -0
- data/examples/latex_templates/Test-springer_article/svjour3.cls +1431 -0
- data/examples/misc/baseball.csv +0 -0
- data/examples/misc/ggplot.rb +3 -2
- data/examples/misc/moneyball.rb +0 -0
- data/examples/misc/subsetting.rb +0 -0
- data/examples/multithread_shards_to_r/shards_to_r.rb +67 -0
- data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.Rmd +73 -0
- data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.Rmd +382 -0
- data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.Rmd +164 -0
- data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.Rmd +92 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/attend-grade-relationships.csv +482 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.Rmd +280 -0
- data/examples/rmarkdown/svm-xaringan-example/svm-xaringan-example.Rmd +386 -0
- data/examples/sthda_ggplot/README.md +0 -0
- data/examples/sthda_ggplot/RUN.md +41 -0
- data/examples/sthda_ggplot/all.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/density_gg.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_area.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_density.rb +2 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_dotplot.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_freqpoly.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_histogram.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/histogram_density.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/stat.rb +0 -0
- data/examples/sthda_ggplot/one_variable_discrete/bar.rb +0 -0
- data/examples/sthda_ggplot/qplots/box_violin_dot.rb +0 -0
- data/examples/sthda_ggplot/qplots/scatter_plots.rb +0 -0
- data/examples/sthda_ggplot/scatter_gg.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_bin2d.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_density2d.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_hex.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_cont/geom_point.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_cont/geom_smooth.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_cont/misc.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_function/geom_area.rb +4 -3
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_bar.rb +0 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_boxplot.rb +0 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_dotplot.rb +0 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_jitter.rb +0 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_line.rb +0 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_violin.rb +0 -0
- data/examples/sthda_ggplot/two_variables_disc_disc/geom_jitter.rb +0 -0
- data/examples/sthda_ggplot/two_variables_error/geom_crossbar.rb +0 -0
- data/ext/new_bridge/Makefile +46 -0
- data/ext/new_bridge/galaaz_gatekeeper_phase0.cpp +12 -0
- data/ext/new_bridge/galaaz_gatekeeper_phase1.cpp +1639 -0
- data/lib/R_interface/galaaz_device.R +20 -0
- data/lib/R_interface/include_engine.R +109 -0
- data/lib/R_interface/new_bridge_adapter.rb +824 -0
- data/lib/R_interface/r.rb +177 -25
- data/lib/R_interface/r_arrow.rb +113 -0
- data/lib/R_interface/r_libs.R +4 -4
- data/lib/R_interface/r_methods.rb +13 -116
- data/lib/R_interface/r_module_s.rb +0 -0
- data/lib/R_interface/rbinary_operators.rb +20 -2
- data/lib/R_interface/rclosure.rb +5 -1
- data/lib/R_interface/rdata_frame.rb +34 -70
- data/lib/R_interface/rdevice.rb +125 -0
- data/lib/R_interface/rdevices.R +0 -0
- data/lib/R_interface/renvironment.rb +10 -4
- data/lib/R_interface/rexpression.rb +5 -1
- data/lib/R_interface/rindexed_object.rb +41 -13
- data/lib/R_interface/rlanguage.rb +20 -62
- data/lib/R_interface/rlist.rb +115 -25
- data/lib/R_interface/rlogical_operators.rb +0 -0
- data/lib/R_interface/rmatrix.rb +2 -11
- data/lib/R_interface/rmd_indexed_object.rb +5 -1
- data/lib/R_interface/robject.rb +348 -290
- data/lib/R_interface/rpkg.rb +1 -0
- data/lib/R_interface/rsupport.rb +610 -331
- data/lib/R_interface/rsupport_scope.rb +2 -1
- data/lib/R_interface/rsymbol.rb +50 -0
- data/lib/R_interface/ruby_callback.rb +2 -3
- data/lib/R_interface/ruby_extensions.rb +225 -175
- data/lib/R_interface/runary_operators.rb +0 -0
- data/lib/R_interface/rvector.rb +147 -31
- data/lib/galaaz.rb +0 -0
- data/lib/galaaz_jruby.rb +22 -0
- data/lib/gknit/diagnostics.rb +50 -0
- data/lib/gknit/draft.rb +111 -0
- data/lib/gknit/include_engine.rb +15 -7
- data/lib/gknit/knitr_engine.rb +223 -107
- data/lib/gknit/rb_engine.rb +3 -3
- data/lib/gknit/ruby_engine.rb +0 -0
- data/lib/gknit.rb +3 -0
- data/lib/new_bridge/bootstrap/windows_bootstrap.rb +285 -0
- data/lib/new_bridge/envelope.rb +51 -0
- data/lib/new_bridge/eval_result.rb +26 -0
- data/lib/new_bridge/framing.rb +39 -0
- data/lib/new_bridge/instance_pool_client.rb +38 -0
- data/lib/new_bridge/r_instance_manager.rb +404 -0
- data/lib/new_bridge/session_client.rb +530 -0
- data/lib/new_bridge/tcp_framed.rb +44 -0
- data/lib/new_bridge.rb +9 -0
- data/lib/util/exec_ruby.rb +95 -46
- data/lib/util/inline_file.rb +35 -30
- data/new_bridge_specs/benchmark_phase5_5_unboxing_spec.rb +96 -0
- data/new_bridge_specs/eval_r_async_spec.rb +113 -0
- data/new_bridge_specs/integration_phase5_1_concurrent_spec.rb +50 -0
- data/new_bridge_specs/integration_phase5_1_eval_spec.rb +16 -0
- data/new_bridge_specs/integration_phase5_1_r_api_spec.rb +25 -0
- data/new_bridge_specs/integration_phase5_1_smoke_spec.rb +31 -0
- data/new_bridge_specs/integration_phase5_2_dataframe_unboxing_spec.rb +19 -0
- data/new_bridge_specs/integration_phase5_2_handle_eval_unboxing_spec.rb +25 -0
- data/new_bridge_specs/integration_phase5_3_callback_args_spec.rb +28 -0
- data/new_bridge_specs/integration_phase5_3_callback_error_spec.rb +22 -0
- data/new_bridge_specs/integration_phase5_3_callback_timeout_spec.rb +28 -0
- data/new_bridge_specs/integration_phase5_3_callbacks_smoke_spec.rb +22 -0
- data/new_bridge_specs/integration_phase5_3_edge_cases_spec.rb +52 -0
- data/new_bridge_specs/integration_phase5_3_nested_spec.rb +30 -0
- data/new_bridge_specs/integration_phase5_4_concurrent_sessions_spec.rb +53 -0
- data/new_bridge_specs/integration_phase5_4_nested_session_callbacks_spec.rb +49 -0
- data/new_bridge_specs/integration_phase5_4_session_routing_spec.rb +38 -0
- data/new_bridge_specs/integration_phase5_5_stress_concurrency_spec.rb +52 -0
- data/new_bridge_specs/integration_phase5_5_unbox_walk_spec.rb +46 -0
- data/new_bridge_specs/phase0_protocol_spec.rb +96 -0
- data/new_bridge_specs/phase1_req_ret_spec.rb +66 -0
- data/new_bridge_specs/phase2_multi_instance_spec.rb +67 -0
- data/new_bridge_specs/phase3_callbacks_spec.rb +71 -0
- data/new_bridge_specs/phase4_2_hardening_spec.rb +252 -0
- data/new_bridge_specs/phase4_3_r_instance_manager_spec.rb +85 -0
- data/new_bridge_specs/phase4_nested_callbacks_spec.rb +123 -0
- data/r_requires/ggplot.rb +0 -0
- data/r_requires/knitr.rb +0 -0
- data/specs/all.rb +15 -11
- data/specs/arrow_from_ruby_batches_spec.rb +50 -0
- data/specs/arrow_semantics_spec.rb +64 -0
- data/specs/bridge_concurrent_spec.rb +46 -0
- data/specs/bridge_nested_spec.rb +25 -0
- data/specs/dataframe_semantics_spec.rb +122 -0
- data/specs/dataframe_single_index_logical_filter_spec.rb +21 -0
- data/specs/dispatch_probe_cache_spec.rb +38 -0
- data/specs/dispatch_probe_error_class_fallback_spec.rb +20 -0
- data/specs/dispatch_probe_fallback_spec.rb +18 -0
- data/specs/environment_semantics_spec.rb +89 -0
- data/specs/field_access_spec.rb +31 -0
- data/specs/figures/bg.jpeg +0 -0
- data/specs/figures/bg.png +0 -0
- data/specs/figures/bg.svg +168 -57
- data/specs/figures/dose_len.png +0 -0
- data/specs/figures/no_args.jpeg +0 -0
- data/specs/figures/no_args.png +0 -0
- data/specs/figures/no_args.svg +168 -57
- data/specs/figures/width_height.jpeg +0 -0
- data/specs/figures/width_height.png +0 -0
- data/specs/figures/width_height_units1.jpeg +0 -0
- data/specs/figures/width_height_units1.png +0 -0
- data/specs/figures/width_height_units2.jpeg +0 -0
- data/specs/figures/width_height_units2.png +0 -0
- data/specs/formula_semantics_spec.rb +81 -0
- data/specs/galaaz_util_exec_ruby_spec.rb +85 -0
- data/specs/galaaz_util_inline_file_spec.rb +54 -0
- data/specs/gknit_cli_option_permutation_spec.rb +24 -0
- data/specs/gknit_include_engine_spec.rb +72 -0
- data/specs/gknit_install_timeout_report_spec.rb +69 -0
- data/specs/gknit_internal_error_report_spec.rb +57 -0
- data/specs/gknit_vector_map_output_spec.rb +59 -0
- data/specs/globalenv_guardrail_spec.rb +52 -0
- data/specs/language_expression_semantics_spec.rb +145 -0
- data/specs/list_semantics_spec.rb +111 -0
- data/specs/new_bridge_bulk_dataframe_transfer_spec.rb +44 -0
- data/specs/new_bridge_bulk_vector_transfer_spec.rb +73 -0
- data/specs/new_bridge_callback_timeout_spec.rb +69 -0
- data/specs/new_bridge_eval_r_fallback_spec.rb +55 -0
- data/specs/nil_null_spec.rb +42 -0
- data/specs/object_build_phase2_spec.rb +53 -0
- data/specs/phase1_callback_bridge_spec.rb +84 -0
- data/specs/phase2_gknit_generic_rendering_guardrail_spec.rb +46 -0
- data/specs/phase2_gknit_no_raw_code_leakage_spec.rb +43 -0
- data/specs/phase3_gknit_generic_graphics_capture_spec.rb +71 -0
- data/specs/plot_device_semantics_spec.rb +28 -0
- data/specs/plot_snapshot_semantics_spec.rb +58 -0
- data/specs/protocol_result_spec.rb +236 -0
- data/specs/r_batch_fail_fast_spec.rb +47 -0
- data/specs/r_bridge_bootstrap_spec.rb +11 -0
- data/specs/r_devices.spec.rb +1 -1
- data/specs/r_eval.spec.rb +16 -18
- data/specs/r_function.spec.rb +1 -1
- data/specs/r_instance_manager_spec.rb +285 -0
- data/specs/r_list_apply.spec.rb +15 -15
- data/specs/r_matrix.spec.rb +0 -0
- data/specs/r_nse.spec.rb +5 -5
- data/specs/r_object_send_dispatch_spec.rb +13 -0
- data/specs/r_vector_comparator_spec.rb +8 -0
- data/specs/r_vector_creation.spec.rb +0 -0
- data/specs/r_vector_functions.spec.rb +0 -0
- data/specs/r_vector_object.spec.rb +0 -0
- data/specs/r_vector_operators.spec.rb +0 -0
- data/specs/r_vector_structured_scalar_reads_spec.rb +35 -0
- data/specs/r_vector_subsetting.spec.rb +0 -0
- data/specs/range_helper_spec.rb +21 -0
- data/specs/rsupport_scope_spec.rb +28 -0
- data/specs/rsupport_var_name_thread_safety_spec.rb +24 -0
- data/specs/scalar_character_spec.rb +44 -0
- data/specs/scoped_symbol_dsl_refinement_spec.rb +40 -0
- data/specs/session_env_bridge_spec.rb +25 -0
- data/specs/simplecov_bootstrap_spec.rb +10 -0
- data/specs/spec_helper.rb +10 -0
- data/specs/tmp.rb +41 -20
- data/specs/unboxing_recursion_regression_spec.rb +30 -0
- data/specs/unboxing_spec.rb +49 -0
- data/specs/verify_callbacks.rb +42 -0
- data/sty/galaaz.sty +0 -0
- data/version.rb +1 -1
- metadata +239 -71
- data/blogs/galaaz_ggplot/galaaz_ggplot.aux +0 -41
- data/blogs/galaaz_ggplot/galaaz_ggplot.html +0 -705
- data/blogs/galaaz_ggplot/galaaz_ggplot.out +0 -10
- data/blogs/galaaz_ggplot/galaaz_ggplot.pdf +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/midwest_rb.pdf +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/scatter_plot_rb.pdf +0 -0
- data/blogs/galaaz_ggplot/midwest.html +0 -188
- data/blogs/gknit/gknit.html +0 -2266
- data/blogs/gknit/gknit.pdf +0 -0
- data/blogs/gknit/gknit.tex +0 -1358
- data/blogs/manual/graph.rb +0 -29
- data/blogs/manual/manual.html +0 -2995
- data/blogs/manual/manual.pdf +0 -0
- data/blogs/manual/manual_files/figure-latex/diverging_bar.pdf +0 -0
- data/blogs/nse_dplyr/nse_dplyr.html +0 -960
- data/blogs/nse_dplyr/nse_dplyr.pdf +0 -0
- data/blogs/nse_dplyr/nse_dplyr.tex +0 -1373
- data/blogs/oh_my/oh_my.html +0 -680
- data/blogs/ruby_plot/ruby_plot.Rmd_external_figs +0 -662
- data/blogs/ruby_plot/ruby_plot.html +0 -729
- data/blogs/ruby_plot/ruby_plot.pdf +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg +0 -57
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg +0 -106
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg +0 -110
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg +0 -174
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg +0 -236
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.svg +0 -296
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg +0 -236
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg +0 -218
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg +0 -128
- data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg +0 -150
- data/examples/paper/paper.rb +0 -36
- data/specs/r_dataframe.spec.rb +0 -379
- data/specs/r_environment.spec.rb +0 -140
- data/specs/r_formula.spec.rb +0 -232
- data/specs/r_language.spec.rb +0 -112
- data/specs/r_list.spec.rb +0 -293
- data/specs/r_plots.spec.rb +0 -72
- data/specs/ruby_expression.spec.rb +0 -315
data/blogs/oh_my/old.Rmd
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Extending R with classes, modules, procs, lambdas, oh my!"
|
|
3
|
+
subtitle: "Archived variant (Renjin-era narrative); see `oh_my.Rmd` and the Galaaz 2.0 manual for current stack"
|
|
3
4
|
author:
|
|
4
5
|
- "Rodrigo Botafogo"
|
|
5
6
|
- "Daniel Mossé - University of Pittsburgh"
|
|
6
|
-
tags: [Tech, Data Science, Ruby, R,
|
|
7
|
+
tags: [Archived, Tech, Data Science, Ruby, R, Renjin]
|
|
7
8
|
date: "November 19th, 2018"
|
|
8
9
|
output:
|
|
9
10
|
html_document:
|
|
@@ -25,11 +26,11 @@ fontsize: 11pt
|
|
|
25
26
|
|
|
26
27
|
# Introduction
|
|
27
28
|
|
|
28
|
-
This paper introduces and compares Galaaz with R's S4. It is
|
|
29
|
+
This paper introduces and compares Galaaz with R's S4. It is **modeled closely** on
|
|
29
30
|
["A '(not so)' Short Introduction to S4"](https://cran.r-project.org/doc/contrib/Genolini-S4tutorialV0-5en.pdf) by Christophe Genolini and follows the same structure and examples presented there.
|
|
30
31
|
|
|
31
32
|
Galaaz is a Ruby Gem (library) that allows very tight integration between Ruby and R.
|
|
32
|
-
|
|
33
|
+
Its integration is tighter and more transparent than what one can get between RinRuby
|
|
33
34
|
or similar solutions in Python
|
|
34
35
|
such as [PypeR](https://pypi.python.org/pypi/PypeR/1.1.0), [rpy2](http://rpy2.bitbucket.org/)
|
|
35
36
|
and other similar solutions. Galaaz targets the Java Virtual Machine and it
|
|
@@ -84,7 +85,7 @@ type information is also not a "compile" time type, since R is not compiled. Th
|
|
|
84
85
|
checked at runtime. The same checking can be done in Ruby and we will do it later in this
|
|
85
86
|
document.
|
|
86
87
|
|
|
87
|
-
In the example
|
|
88
|
+
In the example below, we create
|
|
88
89
|
class Trajectories with two instance variables, 'times' and 'matrix'. We will not go over
|
|
89
90
|
the details of instance variables in Ruby, but here we created those variables with the
|
|
90
91
|
keyword 'attr_reader' and a column before the variables name:
|
|
@@ -101,7 +102,7 @@ end
|
|
|
101
102
|
|
|
102
103
|
|
|
103
104
|
In order to create a new instance of object Trajectories we call method new on the class and
|
|
104
|
-
we can store the result in a
|
|
105
|
+
we can store the result in a variable (not an instance variable) as below:
|
|
105
106
|
|
|
106
107
|
```
|
|
107
108
|
traj = Trajectories.new
|
|
@@ -125,7 +126,7 @@ puts traj.times
|
|
|
125
126
|
Since there is no content stored in 'times' nor 'matrix', nil is returned. In order to add
|
|
126
127
|
a value in the variables, we need to add a constructor the class Trajectories. In R, a
|
|
127
128
|
constructor is build by default, in Ruby, this has to be created by adding a method called
|
|
128
|
-
'initialize'. In the example
|
|
129
|
+
'initialize'. In the example below, we will create the initializer that accepts two values,
|
|
129
130
|
a 'times' value and a 'matrix' value and they are used to initialize the value of the
|
|
130
131
|
instance variables:
|
|
131
132
|
EOT
|
|
@@ -154,7 +155,7 @@ i.e., R functions are all defined in Galaaz in the R namespace.
|
|
|
154
155
|
Since Galaaz is Ruby and not R, some syntax adjustments are sometimes necessary. For instance,
|
|
155
156
|
in R, a range is represented as '(1:4)', in Ruby, the same range is represented as '(1..4)'.
|
|
156
157
|
When passing arguments to an R function in R one uses the '=' sign after the slot name; in R,
|
|
157
|
-
one uses the ':' operator after parameter's name as we can see
|
|
158
|
+
one uses the ':' operator after parameter's name as we can see below:
|
|
158
159
|
EOT
|
|
159
160
|
|
|
160
161
|
```
|
|
@@ -274,7 +275,7 @@ recommend its use, there are many cases in which default values are useful and m
|
|
|
274
275
|
We have already seen default values in this document, with the default being 'nil'. This was
|
|
275
276
|
necessary in order to be able to create our constructor and passing it the proper values.
|
|
276
277
|
|
|
277
|
-
In the example
|
|
278
|
+
In the example below, a class TrajectoriesBis is created with default value 1 for times and a
|
|
278
279
|
matrix with no elements in matrix.
|
|
279
280
|
|
|
280
281
|
```{ruby}
|
|
@@ -377,7 +378,7 @@ Trajectories to add methods to it. In SS4, a method 'plot' is added to Trajecto
|
|
|
377
378
|
point, Renjin and Galaaz do not yet have plotting capabilities, so we will have to skip this
|
|
378
379
|
method and go directly to the implementation of the 'print' method.
|
|
379
380
|
|
|
380
|
-
|
|
381
|
+
Below is the R code for method print:
|
|
381
382
|
|
|
382
383
|
```
|
|
383
384
|
> setMethod ("print","Trajectories",
|
|
@@ -469,7 +470,7 @@ features of Galaaz, some we have already seen, others will be described now:
|
|
|
469
470
|
an R vector that holds a number, then @num.gz is a number that can be used normally with Ruby
|
|
470
471
|
methods;
|
|
471
472
|
|
|
472
|
-
* R functions and Ruby methods can be used freely in Galaaz. We show
|
|
473
|
+
* R functions and Ruby methods can be used freely in Galaaz. We show below two different ways
|
|
473
474
|
of getting the minimum of a number, either by calling R.min or by getting the minimum of an
|
|
474
475
|
array, with the min method;
|
|
475
476
|
|
|
@@ -1191,7 +1192,7 @@ to this point was protected from any changes to those variables. If we need to
|
|
|
1191
1192
|
to those variable, then setters are needed. In this case, the simple setter as shown above is
|
|
1192
1193
|
not ideal, since it would allow changes that break the restriction that variable times has to
|
|
1193
1194
|
have the same length as the number of columns of matrix. In order to do the verification we
|
|
1194
|
-
need to implement a more sophisticated setter. In the example
|
|
1195
|
+
need to implement a more sophisticated setter. In the example below, we add the 'times=' setter
|
|
1195
1196
|
that receives as input one argument. First we convert the given argument to an R object, then
|
|
1196
1197
|
check to see that the length of times is the same as the number of columns and if everything is
|
|
1197
1198
|
fine, then we set the value of instance variable times:
|
|
@@ -1282,7 +1283,7 @@ have already seen in many of the examples above. The example in SS4 presents a
|
|
|
1282
1283
|
different output if its input is numeric, character has both. Let's write a class in Ruby that
|
|
1283
1284
|
does the same for Numeric and String. In Ruby we do not define global functions, we always define
|
|
1284
1285
|
methods inside classes or modules (as we will see later). Also, Ruby is not typed, so methods are
|
|
1285
|
-
not called depending on their types as in SS4 examples.
|
|
1286
|
+
not called depending on their types as in SS4 examples. Below, method test will be called with
|
|
1286
1287
|
one parameter. At the time of calling we do not know the type of the argument, the method can
|
|
1287
1288
|
then check is the received argument is a Numeric or a String and at this time, decide what should
|
|
1288
1289
|
be printed.
|
|
@@ -1774,7 +1775,7 @@ As we can now see, trajCochin and cochin_internal have different content, while
|
|
|
1774
1775
|
still has the same value in index 0, i.e. 15.0, trajCochin matrix has value 1 in index 1. This
|
|
1775
1776
|
shows that Renjin when assigning to trajCochin.matrix[1] makes a copy of the original data.
|
|
1776
1777
|
|
|
1777
|
-
|
|
1778
|
+
Below, we use method 'get' which is a synonym of method 'as__mdarray' to again get the content
|
|
1778
1779
|
of trajCochin.matrix. This variable has as first element the value 1, as set previously.
|
|
1779
1780
|
|
|
1780
1781
|
```
|
|
@@ -1942,7 +1943,7 @@ As you can see, 'ruby.array' is still the same Ruby object.
|
|
|
1942
1943
|
Avatars maintain some properties of their original world. Although the concept of method
|
|
1943
1944
|
chaning is foreign to R, chaining can be used with imported objects from Ruby. Method
|
|
1944
1945
|
chaining occurs when the result of a applying a method on an object returns an object (usually
|
|
1945
|
-
the same object) in which another method can be applied. In the example
|
|
1946
|
+
the same object) in which another method can be applied. In the example below, method '<<'
|
|
1946
1947
|
will be applied multiple times for ruby.array
|
|
1947
1948
|
EOT
|
|
1948
1949
|
|
|
@@ -3,8 +3,8 @@ title: "How to make Beautiful Ruby Plots with Galaaz"
|
|
|
3
3
|
author:
|
|
4
4
|
- "Rodrigo Botafogo"
|
|
5
5
|
- "Daniel Mossé - University of Pittsburgh"
|
|
6
|
-
tags: [Tech, Data Science, Ruby, R,
|
|
7
|
-
date: "November 19th, 2018"
|
|
6
|
+
tags: [Tech, Data Science, Ruby, R, JRuby, "GNU R", Galaaz]
|
|
7
|
+
date: "November 19th, 2018 (narrative updated for Galaaz 2.0, 2026)"
|
|
8
8
|
output:
|
|
9
9
|
html_document:
|
|
10
10
|
self_contained: true
|
|
@@ -31,59 +31,33 @@ general-purpose programming language. It was designed and developed in the mid-1
|
|
|
31
31
|
"Matz" Matsumoto in Japan." It reached high popularity with the development of Ruby on Rails
|
|
32
32
|
(RoR) by David Heinemeier Hansson. RoR is a web application framework first released
|
|
33
33
|
around 2005. It makes extensive use of Ruby's metaprogramming features. With RoR,
|
|
34
|
-
Ruby became very popular. According to [Ruby
|
|
35
|
-
it
|
|
36
|
-
|
|
37
|
-
most popular language.
|
|
34
|
+
Ruby became very popular. According to [Ruby’s ranking in the TIOBE index](https://www.tiobe.com/tiobe-index/ruby/)
|
|
35
|
+
it **peaked** in popularity around 2008, then declined until 2015 when it started picking up again.
|
|
36
|
+
As of the original publication date (November 2018), TIOBE placed Ruby around 16th among languages.
|
|
38
37
|
|
|
39
|
-
Python,
|
|
40
|
-
|
|
38
|
+
Python, often grouped with Ruby as a high-level scripting language, ranked higher in that same snapshot.
|
|
39
|
+
Ruby is often criticized for its focus on web applications.
|
|
41
40
|
But Ruby can do [much more](https://github.com/markets/awesome-ruby) than just web applications.
|
|
42
|
-
Yet, for scientific computing, Ruby lags
|
|
43
|
-
Django
|
|
41
|
+
Yet, for scientific computing, Ruby lags behind Python and R. Python combines web frameworks such as
|
|
42
|
+
Django with NumPy, pandas, SciPy, and **a very large ecosystem** of domain-specific packages.
|
|
44
43
|
R is a free software environment for statistical computing and graphics with thousands
|
|
45
44
|
of libraries for data analysis.
|
|
46
45
|
|
|
47
46
|
Until recently, there was no real perspective for Ruby to bridge this gap.
|
|
48
47
|
Implementing a complete scientific computing infrastructure would take too long.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
> achieve high performance when language boundaries are crossed. Most of the time
|
|
63
|
-
> there is no additional cost for crossing a language boundary at all.
|
|
64
|
-
>
|
|
65
|
-
> Often developers have to make uncomfortable compromises that require them
|
|
66
|
-
> to rewrite their software in other languages. For example:
|
|
67
|
-
>
|
|
68
|
-
> * That library is not available in my language. I need to rewrite it.
|
|
69
|
-
> * That language would be the perfect fit for my problem, but we cannot
|
|
70
|
-
> run it in our environment.
|
|
71
|
-
> * That problem is already solved in my language, but the language is
|
|
72
|
-
> too slow.
|
|
73
|
-
>
|
|
74
|
-
> With GraalVM we aim to allow developers to freely choose the right language for
|
|
75
|
-
> the task at hand without making compromises.
|
|
76
|
-
|
|
77
|
-
As stated above, GraalVM is a _universal_ virtual machine that allows Ruby and R (and other
|
|
78
|
-
languages) to run on the same environment. GraalVM allows polyglot applications to
|
|
79
|
-
_seamlessly_ interact with one another and pass values from one language to the other.
|
|
80
|
-
Although a great idea, GraalVM still requires application writers to know several languages.
|
|
81
|
-
To eliminate that requirement, we built Galaaz, a gem for Ruby, to tightly couple
|
|
82
|
-
Ruby and R and allow those languages to interact in a way that the user will be unaware
|
|
83
|
-
of such interaction. In other words, a Ruby programmer will be able to use all
|
|
84
|
-
the capabilities of R without knowing the R syntax.
|
|
85
|
-
|
|
86
|
-
Library wrapping is a usual way of bringing features from one language into another.
|
|
48
|
+
|
|
49
|
+
**Galaaz 2.0** couples **[JRuby](https://www.jruby.org/)** (Ruby on the JVM) with **GNU R**—the
|
|
50
|
+
same R distribution used for data science everywhere. A **bridge** evaluates R from Ruby and
|
|
51
|
+
exchanges data between the two processes so that, from Ruby, you call R functions and work
|
|
52
|
+
with R objects using familiar Ruby syntax. In other words, a Ruby programmer can use the
|
|
53
|
+
capabilities of R without memorizing all of R’s syntax for day-to-day tasks.
|
|
54
|
+
|
|
55
|
+
An **earlier line of work** used Oracle’s **GraalVM** with **TruffleRuby** and **FastR** so that
|
|
56
|
+
Ruby and R could share one JVM runtime. That stack is **no longer** what Galaaz targets;
|
|
57
|
+
today’s Galaaz is developed and tested with **JRuby + GNU R** (see the project manual for setup
|
|
58
|
+
and command-line tools).
|
|
59
|
+
|
|
60
|
+
Library wrapping is a common way to bring features from one language into another.
|
|
87
61
|
To improve performance, Python often wraps more efficient C libraries. For the
|
|
88
62
|
Python developer, the existence of such C libraries is hidden. The problem with
|
|
89
63
|
library wrapping is that for any new library, there is the need to handcraft a new
|
|
@@ -94,7 +68,7 @@ in Ruby. Doing so, all thousands of R libraries are available immediately
|
|
|
94
68
|
to Ruby developers without any new wrapping effort.
|
|
95
69
|
|
|
96
70
|
To show the power of Galaaz, we show in this article how Ruby can use R's ggplot2
|
|
97
|
-
library
|
|
71
|
+
library **transparently**, bringing to Ruby the power of high-quality scientific plotting.
|
|
98
72
|
We also show that migrating from R to Ruby with Galaaz is a matter of small
|
|
99
73
|
syntactic changes. By using Ruby, the R developer can use all of Ruby's powerful
|
|
100
74
|
object-oriented features. Also, with Ruby, it becomes much easier to move code
|
|
@@ -110,14 +84,14 @@ ggplot themes that will work the same as the Ruby module. Yet, writing a new th
|
|
|
110
84
|
requires specific knowledge on theme writing. Ruby modules are standard to the
|
|
111
85
|
language and don't need special knowledge.
|
|
112
86
|
|
|
113
|
-
[Here](https://towardsdatascience.com/ruby-plotting-with-galaaz-an-example-of-tightly-coupling-ruby-and-r-in-graalvm-520b69e21021)
|
|
87
|
+
[Here](https://towardsdatascience.com/ruby-plotting-with-galaaz-an-example-of-tightly-coupling-ruby-and-r-in-graalvm-520b69e21021) is an older article (GraalVM-era Galaaz) with a scatter plot in Ruby; the **ideas** still apply under Galaaz 2.0 with JRuby and GNU R.
|
|
114
88
|
|
|
115
89
|
# gKnit
|
|
116
90
|
|
|
117
91
|
_Knitr_ is an application that converts text written in rmarkdown to many
|
|
118
92
|
different output formats. For instance, a writer can convert an rmarkdown document
|
|
119
|
-
to HTML,
|
|
120
|
-
text and _code chunks_.
|
|
93
|
+
to HTML, LaTeX, Word, and many other formats. R Markdown documents can contain
|
|
94
|
+
text and _code chunks_. knitr formats code chunks in a shaded box in the output document.
|
|
121
95
|
It also executes the code chunks and formats the output in a white box. Every line of
|
|
122
96
|
output from the execution code is preceded by '##'.
|
|
123
97
|
|
|
@@ -131,7 +105,7 @@ With _gKnit_ Ruby code chunks can share data.
|
|
|
131
105
|
# Exploring the Dataset
|
|
132
106
|
|
|
133
107
|
Let's start by exploring our selected dataset. ToothGrowth is an R dataset. A dataset
|
|
134
|
-
is like a simple
|
|
108
|
+
is like a simple Excel spreadsheet, in which each column has only one type of data.
|
|
135
109
|
For instance one column can have float, the other integer, and a third strings.
|
|
136
110
|
This dataset analyzes the length of odontoblasts (cells responsible for tooth growth)
|
|
137
111
|
in 60 guinea pigs, where each animal received one of three dose levels of Vitamin C
|
|
@@ -140,15 +114,15 @@ in 60 guinea pigs, where each animal received one of three dose levels of Vitami
|
|
|
140
114
|
|
|
141
115
|
The ToothGrowth dataset contains three columns: 'len', 'supp' and 'dose'. Let's
|
|
142
116
|
take a look at a few rows of this dataset. In Galaaz, R variables are accessed
|
|
143
|
-
by using the corresponding Ruby symbol
|
|
117
|
+
by using the corresponding Ruby symbol with the tilde (`~`) operator. Note in the
|
|
144
118
|
following chunk that 'ToothGrowth' is the R variable and Ruby's 'tooth_growth' is
|
|
145
|
-
assigned the value of '
|
|
119
|
+
assigned the value of '~R[:ToothGrowth]'.
|
|
146
120
|
|
|
147
121
|
```{ruby head}
|
|
148
122
|
# Read the R ToothGrowth variable and assign it to the
|
|
149
123
|
# Ruby instance variable tooth_growth that will be
|
|
150
124
|
# available to all Ruby chunks in this document.
|
|
151
|
-
tooth_growth =
|
|
125
|
+
tooth_growth = ~R[:ToothGrowth]
|
|
152
126
|
# print the first few elements of the dataset
|
|
153
127
|
puts tooth_growth.head
|
|
154
128
|
```
|
|
@@ -166,7 +140,7 @@ puts tooth_growth.len.head
|
|
|
166
140
|
|
|
167
141
|
The 'dose' column contains a numeric value with either, 0.5, 1 or 2, although the
|
|
168
142
|
first 6 rows as seen above only contain the 0.5 values. Even though those are
|
|
169
|
-
number, they are better interpreted as a [factor or
|
|
143
|
+
number, they are better interpreted as a [factor or category](https://swcarpentry.github.io/r-novice-inflammation/12-supp-factors/). So, let's convert our 'dose' column from numeric to 'factor'.
|
|
170
144
|
In R, the function 'as.factor' is used to convert data in a vector to factors. To use this
|
|
171
145
|
function from Galaaz the dot ('.') in the function name is substituted by '__' (double underline).
|
|
172
146
|
The function 'as.factor' becomes 'R.as__factor' or just 'as__factor' when chaining.
|
|
@@ -221,7 +195,7 @@ to form the final graphics.
|
|
|
221
195
|
In order to make a plot, we use the 'ggplot' function to the dataset. In R, this would be
|
|
222
196
|
written as ```ggplot(<dataset>, ...)```. Galaaz gives you the flexibility to use
|
|
223
197
|
either ```R.ggplot(<dataset>, ...)``` or ```<dataset>.ggplot(...)```. In the graph
|
|
224
|
-
specification
|
|
198
|
+
specification below, we use the second notation that looks more like Ruby.
|
|
225
199
|
ggplot uses the ‘aes’ method to specify
|
|
226
200
|
x and y axes; in this case, the 'dose' on the $x$ axis and the 'length' on
|
|
227
201
|
the $y$ axis: 'E.aes(x: :dose, y: :len)'. To specify the type of plot add a geom to
|
|
@@ -254,16 +228,16 @@ the 'facet_grid' method is a [_formula_](https://thomasleeper.com/Rcourse/Tutori
|
|
|
254
228
|
|
|
255
229
|
In Galaaz we give programmers the flexibility to use two different ways to write formulas.
|
|
256
230
|
In the first way, we use Ruby expressions and the '.til' function. The formula 'x ~ y', becomes
|
|
257
|
-
':x.til :y'. More information on expressions can be found in [Galaaz Manual](https://www.rubydoc.info/gems/galaaz/).
|
|
231
|
+
'R[:x].til :y'. More information on expressions can be found in [Galaaz Manual](https://www.rubydoc.info/gems/galaaz/).
|
|
258
232
|
|
|
259
233
|
|
|
260
234
|
Another way of writing a formula is to use the 'formula' function with the actual formula as
|
|
261
235
|
a string. The formula ```x ~ y``` in R can be written as ```R.formula("x ~ y")```. For more
|
|
262
236
|
complex formulas, the use of the 'formula' function is preferred.
|
|
263
237
|
|
|
264
|
-
The formula
|
|
238
|
+
The formula ```R[:all].til :supp``` indicates to the 'facet_grid' function that it needs to
|
|
265
239
|
facet the plot based on the ```supp``` variable and split the plot vertically. Changing
|
|
266
|
-
the formula to
|
|
240
|
+
the formula to ```R[:supp].til :all``` would split the plot horizontally.
|
|
267
241
|
|
|
268
242
|
```{ruby facet_by_delivery, dev = "png", fig.width = 540, fig.height = 560, units = "px"}
|
|
269
243
|
|
|
@@ -271,8 +245,8 @@ base_tooth = tooth_growth.ggplot(E.aes(x: :dose, y: :len, group: :dose))
|
|
|
271
245
|
|
|
272
246
|
bp = base_tooth + R.geom_boxplot +
|
|
273
247
|
# Split in vertical direction
|
|
274
|
-
R.facet_grid(:all.til :supp)
|
|
275
|
-
|
|
248
|
+
R.facet_grid(R[:all].til :supp)
|
|
249
|
+
|
|
276
250
|
puts bp
|
|
277
251
|
```
|
|
278
252
|
|
|
@@ -407,7 +381,7 @@ a boxplot known as a _violin plot_ with jittered data.
|
|
|
407
381
|
|
|
408
382
|
```{ruby violin_with_jitter, dev = "png", fig.width = 540, fig.height = 560, units = "px"}
|
|
409
383
|
violin = base_tooth + R.geom_violin(E.aes(fill: :dose)) +
|
|
410
|
-
R.facet_grid(:all.til :supp) +
|
|
384
|
+
R.facet_grid(R[:all].til :supp) +
|
|
411
385
|
R.geom_jitter(shape: 23, color: "cyan3", size: 1) +
|
|
412
386
|
R.scale_fill_manual(values: R.c("cyan", "deepskyblue", "deepskyblue4"),
|
|
413
387
|
breaks: R.c("2","1","0.5"))
|
|
@@ -550,7 +524,7 @@ Each animal received one of three dose levels of vitamin C.
|
|
|
550
524
|
EOT
|
|
551
525
|
|
|
552
526
|
bp = tooth_growth.ggplot(E.aes(x: :supp, y: :len, group: :supp)) +
|
|
553
|
-
R.geom_boxplot(E.aes(fill: :supp)) + R.facet_grid(:all.til :dose) +
|
|
527
|
+
R.geom_boxplot(E.aes(fill: :supp)) + R.facet_grid(R[:all].til :dose) +
|
|
554
528
|
R.scale_fill_manual(values: R.c("cyan", "deepskyblue4")) +
|
|
555
529
|
R.labs(title: "Tooth Growth: Length by Dose",
|
|
556
530
|
subtitle: "Faceted by dose",
|
|
@@ -571,17 +545,17 @@ developer, migration to Ruby is a matter of small syntactic changes with a very
|
|
|
571
545
|
learning curve. As the R developer becomes more proficient in Ruby, he can start using
|
|
572
546
|
'classes', 'modules', 'procs', 'lambdas'.
|
|
573
547
|
|
|
574
|
-
Trying to bring to Ruby the power of R starting from scratch is an
|
|
548
|
+
Trying to bring to Ruby the power of R starting from scratch is an enormous endeavour
|
|
575
549
|
and would probably never be accomplished. Today's data scientists would certainly
|
|
576
550
|
stick with either Python or R. Now, both the Ruby and R communities can benefit
|
|
577
|
-
from this marriage
|
|
578
|
-
|
|
579
|
-
process
|
|
580
|
-
|
|
551
|
+
from this marriage: **Galaaz 2.0** uses **standard GNU R** for statistics and graphics
|
|
552
|
+
and **JRuby** for application code, threading, and the JVM ecosystem. We presented
|
|
553
|
+
the process to couple Ruby and R; the coupling is implemented by the Galaaz bridge and
|
|
554
|
+
**gKnit** for literate documents, not by a single GraalVM polyglot runtime.
|
|
581
555
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
556
|
+
For performance, expect **ordinary GNU R** behaviour for model fitting and plotting, while
|
|
557
|
+
**JRuby** gives **real parallel threads** on the Ruby side and access to Java libraries when
|
|
558
|
+
you need them.
|
|
585
559
|
|
|
586
560
|
This article has shown how to improve a plot step-by-step. Starting from a very simple
|
|
587
561
|
boxplot with all default configurations, we moved slowly to our final plot. The important
|
|
@@ -595,11 +569,11 @@ be of great help for any Rubyist trying to write articles, blogs or documentatio
|
|
|
595
569
|
|
|
596
570
|
# Installing Galaaz
|
|
597
571
|
|
|
598
|
-
## Prerequisites
|
|
572
|
+
## Prerequisites (Galaaz 2.0)
|
|
599
573
|
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
574
|
+
* **JRuby** — Ruby on the JVM ([jruby.org](https://www.jruby.org/))
|
|
575
|
+
* A **JDK** compatible with your JRuby version
|
|
576
|
+
* **GNU R** — `R` on your `PATH`, with compilers/tools available if packages must be built from source
|
|
603
577
|
|
|
604
578
|
The following R packages will be automatically installed when necessary, but could be installed prior
|
|
605
579
|
to using gKnit if desired:
|
|
@@ -608,14 +582,16 @@ to using gKnit if desired:
|
|
|
608
582
|
* gridExtra
|
|
609
583
|
* knitr
|
|
610
584
|
|
|
611
|
-
Installation of R packages requires a development environment and can be time consuming.
|
|
612
|
-
the
|
|
585
|
+
Installation of R packages requires a development environment and can be time consuming. On Linux,
|
|
586
|
+
the usual build tools (e.g. a C/C++ compiler) are typically enough. On macOS, Xcode command-line tools
|
|
587
|
+
are commonly required.
|
|
613
588
|
|
|
614
589
|
## Preparation
|
|
615
590
|
|
|
616
|
-
* gem
|
|
591
|
+
* Install the **galaaz** gem (from RubyGems when published, or `gem build` / `path:` from a checkout).
|
|
617
592
|
|
|
618
593
|
## Usage
|
|
619
594
|
|
|
620
|
-
* gknit
|
|
621
|
-
* In
|
|
595
|
+
* From the Galaaz repository (or your installed layout), render documents with **`bin/gknit`** (see the project manual for flags such as `--output_format all`).
|
|
596
|
+
* In Ruby code: `require 'galaaz'`
|
|
597
|
+
* For running scripts with the correct JRuby and JVM options, use **`bin/galaaz-jruby`** as described in the manual.
|