galaaz 0.5.0 → 2.1.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 +46 -0
- data/LICENSE +0 -0
- data/README.md +1416 -667
- data/Rakefile +68 -41
- data/bin/galaaz-bootstrap +137 -0
- data/bin/galaaz-jruby +11 -0
- data/bin/galaaz-ruby +16 -0
- data/bin/galaaz_jruby_env.inc.sh +6 -0
- data/bin/galaaz_ruby_env.inc.sh +36 -0
- data/bin/gbookdown +63 -0
- data/bin/gknit +83 -13
- data/bin/gknit-draft.rb +0 -0
- data/bin/gstudio +5 -3
- data/bin/gstudio_irb.rb +0 -0
- data/bin/gstudio_pry.rb +0 -0
- data/bin/install-tinytex +6 -0
- data/bin/run_all_rspec +44 -0
- data/bin/run_example +17 -0
- data/bin/run_old_rspec +20 -0
- data/bin/run_rspec +24 -0
- data/bin/run_rspec_subset +38 -0
- data/bin/run_slow_rspec +20 -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 +115 -155
- data/blogs/galaaz_ggplot/galaaz_ggplot.tex +607 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-gfm/midwest_rb.png +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-gfm/scatter_plot_rb.png +0 -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 +47 -52
- data/blogs/gknit/gknit.md +1430 -0
- data/blogs/gknit/gknit_files/figure-gfm/bubble-1.png +0 -0
- data/blogs/gknit/gknit_files/figure-gfm/diverging_bar.png +0 -0
- 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 +855 -239
- data/blogs/manual/manual.log +1786 -0
- data/blogs/manual/manual.md +1416 -667
- data/blogs/manual/manual.tex +1883 -1161
- 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 +1 -1
- data/blogs/nse_dplyr/nse_dplyr.Rmd +84 -111
- data/blogs/nse_dplyr/nse_dplyr.log +928 -0
- data/blogs/nse_dplyr/nse_dplyr.md +198 -229
- 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 +1663 -86
- 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 -102
- data/blogs/ruby_plot/ruby_plot.tex +940 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-gfm/dose_len.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facet_by_delivery.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facet_by_dose.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_by_delivery_color.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_by_delivery_color2.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_with_decorations.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_with_points.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-gfm/final_box_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-gfm/final_violin_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-gfm/violin_with_jitter.png +0 -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/blogs/test/test.md +10 -0
- data/examples/50Plots_MasterList/Images/midwest-scatterplot.PNG +0 -0
- data/examples/50Plots_MasterList/ScatterPlot.rb +2 -1
- data/examples/50Plots_MasterList/scatter_plot.rb +1 -0
- data/examples/Bibliography/master.bib +0 -0
- data/examples/Bibliography/stats.bib +0 -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 +54 -0
- data/examples/bioconductor_deseq2_airway/bench_r_three_same_process.R +34 -0
- data/examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb +34 -0
- data/examples/bioconductor_deseq2_airway/deseq2_airway_galaaz_optimized.rb +35 -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 +14 -0
- data/examples/islr/ch2.spec.rb +38 -7
- data/examples/islr/ch3.spec.rb +12 -2
- data/examples/islr/ch3_boston.rb +28 -0
- data/examples/islr/ch3_multiple_regression.rb +1 -0
- data/examples/islr/ch6.spec.rb +25 -1
- data/examples/islr/x_y_rnorm.jpg +0 -0
- data/examples/latex_templates/Test-acm_article/acm_proc_article-sp.cls +0 -0
- data/examples/latex_templates/Test-acm_article/sigproc.bib +0 -0
- data/examples/latex_templates/Test-acs_article/acs-Test-acs_article.bib +0 -0
- data/examples/latex_templates/Test-acs_article/acs-my_output.bib +0 -0
- data/examples/latex_templates/Test-aea_article/BibFile.bib +0 -0
- data/examples/latex_templates/Test-aea_article/Test-aea_article.Rmd +0 -0
- data/examples/latex_templates/Test-aea_article/references.bib +0 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.Rmd +0 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.pdfsync +0 -0
- data/examples/latex_templates/Test-ieee_article/IEEEtran.bst +0 -0
- data/examples/latex_templates/Test-ieee_article/mybibfile.bib +0 -0
- data/examples/latex_templates/Test-rjournal_article/RJournal.sty +0 -0
- data/examples/latex_templates/Test-rjournal_article/RJreferences.bib +0 -0
- data/examples/latex_templates/Test-rjournal_article/Test-rjournal_article.Rmd +0 -0
- data/examples/misc/baseball.csv +0 -0
- data/examples/misc/ggplot.rb +5 -3
- data/examples/misc/moneyball.rb +1 -0
- data/examples/misc/subsetting.rb +1 -0
- data/examples/multithread_shards_to_r/shards_to_r.rb +68 -0
- data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.Rmd +0 -0
- data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.Rmd +0 -0
- data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.Rmd +0 -0
- data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.Rmd +0 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/attend-grade-relationships.csv +0 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.Rmd +0 -0
- data/examples/rmarkdown/svm-xaringan-example/svm-xaringan-example.Rmd +0 -0
- data/examples/sthda_ggplot/README.md +0 -0
- data/examples/sthda_ggplot/RUN.md +41 -0
- data/examples/sthda_ggplot/all.rb +1 -0
- data/examples/sthda_ggplot/one_variable_continuous/density_gg.rb +1 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_area.rb +1 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_density.rb +3 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_dotplot.rb +1 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_freqpoly.rb +1 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_histogram.rb +1 -0
- data/examples/sthda_ggplot/one_variable_continuous/histogram_density.rb +1 -0
- data/examples/sthda_ggplot/one_variable_continuous/stat.rb +1 -0
- data/examples/sthda_ggplot/one_variable_discrete/bar.rb +1 -0
- data/examples/sthda_ggplot/qplots/box_violin_dot.rb +1 -0
- data/examples/sthda_ggplot/qplots/scatter_plots.rb +1 -0
- data/examples/sthda_ggplot/scatter_gg.rb +1 -0
- data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_bin2d.rb +1 -0
- data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_density2d.rb +1 -0
- data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_hex.rb +1 -0
- data/examples/sthda_ggplot/two_variables_cont_cont/geom_point.rb +1 -0
- data/examples/sthda_ggplot/two_variables_cont_cont/geom_smooth.rb +1 -0
- data/examples/sthda_ggplot/two_variables_cont_cont/misc.rb +1 -0
- data/examples/sthda_ggplot/two_variables_cont_function/geom_area.rb +5 -3
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_bar.rb +1 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_boxplot.rb +1 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_dotplot.rb +1 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_jitter.rb +1 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_line.rb +1 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_violin.rb +1 -0
- data/examples/sthda_ggplot/two_variables_disc_disc/geom_jitter.rb +1 -0
- data/examples/sthda_ggplot/two_variables_error/geom_crossbar.rb +1 -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 +3 -3
- data/lib/R_interface/r_methods.rb +13 -126
- 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 +0 -0
- data/lib/R_interface/rsupport.rb +609 -328
- 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 +162 -31
- data/lib/galaaz.rb +0 -0
- data/lib/galaaz_jruby.rb +22 -0
- data/lib/galaaz_ruby.rb +34 -0
- data/lib/gknit/diagnostics.rb +50 -0
- data/lib/gknit/draft.rb +23 -17
- data/lib/gknit/include_engine.rb +15 -7
- data/lib/gknit/knitr_engine.rb +223 -74
- data/lib/gknit/rb_engine.rb +3 -3
- data/lib/gknit/ruby_engine.rb +0 -0
- data/lib/gknit.rb +1 -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 -20
- 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 +0 -0
- 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 +219 -63
- data/blogs/galaaz_ggplot/galaaz_ggplot.html +0 -520
- data/blogs/galaaz_ggplot/galaaz_ggplot.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/manual/manual.html +0 -4638
- 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 -878
- data/blogs/nse_dplyr/nse_dplyr.pdf +0 -0
- data/blogs/oh_my/oh_my.html +0 -568
- data/blogs/ruby_plot/ruby_plot.html +0 -544
- data/blogs/ruby_plot/ruby_plot.pdf +0 -0
- data/examples/latex_templates/Test-acs_article/Test-acs_article.pdf +0 -0
- data/examples/latex_templates/Test-aea_article/Test-aea_article.pdf +0 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.pdf +0 -0
- data/examples/latex_templates/Test-amq_article/pics/Figure2.pdf +0 -0
- data/examples/latex_templates/Test-asa_article/Test-asa_article.pdf +0 -0
- data/examples/latex_templates/Test-ieee_article/Test-ieee_article.pdf +0 -0
- data/examples/latex_templates/Test-rjournal_article/RJwrapper.pdf +0 -0
- data/examples/latex_templates/Test-springer_article/Test-springer_article.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.pdf +0 -0
- 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 -316
data/lib/R_interface/r.rb
CHANGED
|
@@ -21,14 +21,46 @@
|
|
|
21
21
|
# OR MODIFICATIONS.
|
|
22
22
|
##########################################################################################
|
|
23
23
|
|
|
24
|
+
require 'fileutils'
|
|
25
|
+
require 'msgpack'
|
|
26
|
+
|
|
24
27
|
# Load required R libraries
|
|
25
28
|
dir = File.dirname(File.expand_path('.', __FILE__))
|
|
26
|
-
Polyglot.eval_file('R', "#{dir}/r_libs.R")
|
|
29
|
+
# Polyglot.eval_file('R', "#{dir}/r_libs.R")
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
# Bridge and Support first
|
|
29
32
|
require_relative 'rsupport'
|
|
30
33
|
|
|
34
|
+
# Operator modules next (so R::Object can include them)
|
|
35
|
+
require_relative 'rbinary_operators'
|
|
36
|
+
require_relative 'runary_operators'
|
|
37
|
+
require_relative 'rlogical_operators'
|
|
38
|
+
require_relative 'rindexed_object'
|
|
39
|
+
require_relative 'rmd_indexed_object'
|
|
40
|
+
|
|
41
|
+
# Now R::Object
|
|
42
|
+
require_relative 'robject'
|
|
43
|
+
|
|
31
44
|
module R
|
|
45
|
+
def self.[](name)
|
|
46
|
+
R::SymbolRef.new(name)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Raised when R.batch hits an R error mid-batch (later ops are not executed).
|
|
50
|
+
class BatchEvaluationError < StandardError
|
|
51
|
+
attr_reader :failed_index
|
|
52
|
+
|
|
53
|
+
def initialize(message, failed_index = nil)
|
|
54
|
+
super(message)
|
|
55
|
+
@failed_index = failed_index
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# R↔Ruby bridge: NewBridge only.
|
|
60
|
+
def self.bridge
|
|
61
|
+
require_relative 'new_bridge_adapter'
|
|
62
|
+
R::NewBridgeAdapter.instance
|
|
63
|
+
end
|
|
32
64
|
|
|
33
65
|
RCONSTANTS = ["LETTERS", "letters", "month.abb", "month.name", "pi"]
|
|
34
66
|
|
|
@@ -56,51 +88,166 @@ module R
|
|
|
56
88
|
R::Support.process_missing(symbol, true, *args)
|
|
57
89
|
end
|
|
58
90
|
|
|
91
|
+
# Queue several eval_r_with_result assignments and send them in one bridge round-trip.
|
|
92
|
+
# Fail-fast: on the first R error, remaining queued ops are not run (+R::BatchEvaluationError+,
|
|
93
|
+
# +#failed_index+ is 0-based). Same outcomes as sequential +eval_r_with_result+ when all succeed.
|
|
94
|
+
def self.batch
|
|
95
|
+
col = R::Support::BatchCollector.new
|
|
96
|
+
yield col
|
|
97
|
+
raise ArgumentError, 'R.batch requires at least one eval_with_result assignment' if col.ops.empty?
|
|
98
|
+
|
|
99
|
+
R::Support.batch_eval_with_result(col.ops)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Async string eval against R; +block+ receives +NewBridge::EvalResult+ (+#value+ matches +eval_r+ on success).
|
|
103
|
+
def self.eval_r_async(code, timeout: nil, &block)
|
|
104
|
+
R.bridge.eval_r_async(code, timeout: timeout, &block)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Async R function calls without blocking the caller. Requires a block; completion receives +NewBridge::EvalResult+.
|
|
108
|
+
# (+R.foo { ... }+ is reserved for dplyr-style scopes; use +R::Async.foo(...)+ for async completion.)
|
|
109
|
+
module Async
|
|
110
|
+
def self.method_missing(symbol, *args, **kwargs, &block)
|
|
111
|
+
raise ArgumentError, 'R::Async method calls require a block' unless block
|
|
112
|
+
|
|
113
|
+
timeout = kwargs.delete(:timeout)
|
|
114
|
+
name = R::Support.convert_symbol2r(symbol)
|
|
115
|
+
R::Support.exec_function_async(name, *args, timeout: timeout, **kwargs, &block)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
59
119
|
#----------------------------------------------------------------------------------------
|
|
60
120
|
# Checks to see if the given libs are installed in R and if not, install them
|
|
61
121
|
# @param libs [Array] Array of strings with the names of the libraries to check and
|
|
62
122
|
# install
|
|
63
123
|
#----------------------------------------------------------------------------------------
|
|
64
124
|
|
|
65
|
-
def self.
|
|
125
|
+
def self.with_callback_timeout_ms(callback_timeout_ms)
|
|
126
|
+
return yield if callback_timeout_ms.nil?
|
|
127
|
+
|
|
128
|
+
old = ENV['GALAAZ_CALLBACK_TIMEOUT_MS']
|
|
129
|
+
ENV['GALAAZ_CALLBACK_TIMEOUT_MS'] = Integer(callback_timeout_ms).to_s
|
|
130
|
+
yield
|
|
131
|
+
ensure
|
|
132
|
+
ENV['GALAAZ_CALLBACK_TIMEOUT_MS'] = old unless callback_timeout_ms.nil?
|
|
133
|
+
end
|
|
66
134
|
|
|
67
|
-
|
|
135
|
+
def self.install_rlibs(*libs, install_timeout_sec: nil, callback_timeout_ms: nil, bridge_timeout_sec: nil)
|
|
136
|
+
with_callback_timeout_ms(callback_timeout_ms) do
|
|
68
137
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
138
|
+
# Use a fixed local library directory and ensure R can see it
|
|
139
|
+
lib_dir = File.expand_path("~/R/x86_64-pc-linux-gnu-library/galaaz")
|
|
140
|
+
FileUtils.mkdir_p(lib_dir) unless Dir.exist?(lib_dir)
|
|
141
|
+
R.bridge.eval_r(".libPaths(c('#{lib_dir.gsub("'", "\\\\'")}', .libPaths()))", timeout: bridge_timeout_sec)
|
|
142
|
+
|
|
143
|
+
packages = R.c(*libs)
|
|
144
|
+
|
|
145
|
+
# installed.packages() returns a matrix; package names are in the row names.
|
|
146
|
+
# Using [:all, "Package"] on this matrix ends up calling [[ with a missing
|
|
147
|
+
# row subscript in R, which raises "missing subscript". Instead, rely on
|
|
148
|
+
# the row names vector for the list of installed packages.
|
|
149
|
+
installed_mat = R.installed__packages(nil)
|
|
150
|
+
installed_names = R.rownames(installed_mat)
|
|
151
|
+
|
|
152
|
+
new_packages = packages[!(packages._ :in, installed_names)]
|
|
153
|
+
new_packages_str = new_packages.to_s
|
|
154
|
+
|
|
155
|
+
if(new_packages.length > 0 && new_packages_str != "character(0)")
|
|
156
|
+
$stderr.puts "[RUBY] The following packages are missing and will be installed: #{new_packages_str}"
|
|
157
|
+
$stderr.puts "[RUBY] Installing to: #{lib_dir}"
|
|
158
|
+
|
|
159
|
+
# Get packages as Ruby array using :native mode
|
|
160
|
+
pkg_list = []
|
|
161
|
+
new_packages.each(:native) { |pkg| pkg_list << pkg }
|
|
162
|
+
$stderr.puts "[RUBY] Package list: #{pkg_list.inspect}"
|
|
72
163
|
|
|
73
|
-
#
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
164
|
+
# Install each package
|
|
165
|
+
pkg_list.each do |pkg|
|
|
166
|
+
$stderr.puts "[RUBY] Installing #{pkg}..."
|
|
167
|
+
if install_timeout_sec
|
|
168
|
+
timeout_i = Integer(install_timeout_sec)
|
|
169
|
+
R.bridge.eval_r("options(timeout=#{timeout_i})", timeout: bridge_timeout_sec)
|
|
170
|
+
end
|
|
171
|
+
r_cmd = "install.packages('#{pkg.gsub("'", "\\\\'")}', repos='https://cloud.r-project.org', lib='#{lib_dir.gsub("'", "\\\\'")}', dependencies=NA)"
|
|
172
|
+
$stderr.puts "[RUBY] R command: #{r_cmd}"
|
|
173
|
+
result = R.bridge.eval_r(r_cmd, timeout: bridge_timeout_sec)
|
|
174
|
+
$stderr.puts "[RUBY] Install output: #{result.inspect}"
|
|
175
|
+
if result.to_s.include?("ANTICONF") || result.to_s.include?("Configuration failed")
|
|
176
|
+
$stderr.puts "[RUBY] WARNING: Package #{pkg} failed to install due to missing system libraries."
|
|
177
|
+
$stderr.puts "[RUBY] For kableExtra, you may need: libfontconfig1-dev libxml2-dev libfreetype6-dev"
|
|
178
|
+
end
|
|
179
|
+
ensure
|
|
180
|
+
begin
|
|
181
|
+
R.bridge.eval_r("options(timeout=60)", timeout: bridge_timeout_sec)
|
|
182
|
+
rescue StandardError
|
|
183
|
+
nil
|
|
184
|
+
end
|
|
78
185
|
end
|
|
79
186
|
|
|
80
|
-
|
|
81
|
-
R.
|
|
187
|
+
# Re-check installed packages after install attempt
|
|
188
|
+
installed_mat = R.installed__packages(nil)
|
|
189
|
+
installed_names = R.rownames(installed_mat)
|
|
190
|
+
still_missing = packages[!(packages._ :in, installed_names)]
|
|
191
|
+
if still_missing.length > 0
|
|
192
|
+
raise "Failed to install packages: #{still_missing.to_s}. Check stderr output above for [RUBY] debug messages."
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
82
196
|
end
|
|
83
|
-
|
|
84
197
|
end
|
|
85
198
|
|
|
86
199
|
#----------------------------------------------------------------------------------------
|
|
87
200
|
#
|
|
88
201
|
#----------------------------------------------------------------------------------------
|
|
89
202
|
|
|
90
|
-
def self.install_and_loads(*libs)
|
|
91
|
-
R.install_rlibs(*libs)
|
|
92
|
-
|
|
203
|
+
def self.install_and_loads(*libs, install_timeout_sec: nil, callback_timeout_ms: nil, bridge_timeout_sec: nil)
|
|
204
|
+
R.install_rlibs(*libs, install_timeout_sec: install_timeout_sec, callback_timeout_ms: callback_timeout_ms, bridge_timeout_sec: bridge_timeout_sec)
|
|
205
|
+
# Use library() so load failures throw immediately with a clear R error
|
|
206
|
+
libs.each { |lib| R.library(lib) }
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
#--------------------------------------------------------------------------
|
|
210
|
+
# rlang helpers (reintroduced legacy API surface)
|
|
211
|
+
#--------------------------------------------------------------------------
|
|
212
|
+
|
|
213
|
+
def self.ensure_rlang!
|
|
214
|
+
ok = R::Support.eval("requireNamespace('rlang', quietly=TRUE)")
|
|
215
|
+
return if ok == true
|
|
216
|
+
|
|
217
|
+
raise "R package 'rlang' is required for this API. Install with: Rscript -e \"install.packages('rlang', repos='https://cloud.r-project.org/')\""
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Build an R expression/symbol using rlang::expr().
|
|
221
|
+
def self.expr(arg)
|
|
222
|
+
ensure_rlang!
|
|
223
|
+
var_name = R::Support.generate_var_name
|
|
224
|
+
parsed = R::Support.parse_arg(arg)
|
|
225
|
+
R.bridge.eval_r("#{var_name} <- rlang::expr(#{parsed})")
|
|
226
|
+
R::Object.build(var_name)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# Build a call object with rlang::call2().
|
|
230
|
+
def self.call2(fn, *args, **kwargs)
|
|
231
|
+
ensure_rlang!
|
|
232
|
+
var_name = R::Support.generate_var_name
|
|
233
|
+
parts = [R::Support.parse_arg(fn)]
|
|
234
|
+
parts.concat(args.map { |a| R::Support.parse_arg(a) }) unless args.empty?
|
|
235
|
+
unless kwargs.empty?
|
|
236
|
+
kw = kwargs.map { |k, v| "#{k.to_s.gsub(/__/, ".")} = #{R::Support.parse_arg(v)}" }
|
|
237
|
+
parts.concat(kw)
|
|
238
|
+
end
|
|
239
|
+
R.bridge.eval_r("#{var_name} <- rlang::call2(#{parts.join(', ')})")
|
|
240
|
+
R::Object.build(var_name)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# Execute a function call with dynamic args via rlang::exec().
|
|
244
|
+
def self.exec(fn, *args, **kwargs)
|
|
245
|
+
ensure_rlang!
|
|
246
|
+
R.rlang___exec(fn, *args, **kwargs)
|
|
93
247
|
end
|
|
94
248
|
|
|
95
249
|
end
|
|
96
250
|
|
|
97
|
-
# Binary operators: '+', '-', etc
|
|
98
|
-
require_relative 'rbinary_operators'
|
|
99
|
-
# Unary operators: '!', '@-', etc
|
|
100
|
-
require_relative 'runary_operators'
|
|
101
|
-
# Logical operators
|
|
102
|
-
require_relative 'rlogical_operators'
|
|
103
|
-
|
|
104
251
|
# Ruby class extensions. Extends Symbol to allow the creation of
|
|
105
252
|
# expressions using Symbol: (:x > 10)
|
|
106
253
|
require_relative 'ruby_extensions'
|
|
@@ -128,8 +275,13 @@ require_relative 'renvironment'
|
|
|
128
275
|
require_relative 'rlanguage'
|
|
129
276
|
# Definition of R Symbol
|
|
130
277
|
require_relative 'rsymbol'
|
|
278
|
+
# Device for ggplot (png/svg, plot_snapshot, save_plot)
|
|
279
|
+
require_relative 'rdevice'
|
|
131
280
|
# Access to package symbols
|
|
132
281
|
require_relative 'rpkg'
|
|
133
282
|
|
|
283
|
+
# Arrow helpers (tables, datasets, Feather/Parquet IO)
|
|
284
|
+
require_relative 'r_arrow'
|
|
285
|
+
|
|
134
286
|
# Class to allow R calling back into Ruby
|
|
135
287
|
require_relative 'ruby_callback'
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
##########################################################################################
|
|
4
|
+
# Arrow helpers for Galaaz
|
|
5
|
+
#
|
|
6
|
+
# These methods provide a small, Ruby-friendly surface over common R Arrow
|
|
7
|
+
# operations (tables, datasets, Feather/Parquet IO). They are thin wrappers
|
|
8
|
+
# around the R Arrow package and keep all Arrow data resident in the R process.
|
|
9
|
+
##########################################################################################
|
|
10
|
+
|
|
11
|
+
module R
|
|
12
|
+
module Arrow
|
|
13
|
+
|
|
14
|
+
# Build an Arrow table in R from Ruby-produced batches.
|
|
15
|
+
#
|
|
16
|
+
# Input shapes:
|
|
17
|
+
# - Array<Hash>: each hash is a row
|
|
18
|
+
# - Array<Array<Hash>>: each inner array is a row batch
|
|
19
|
+
# - Any Enumerable yielding Hash rows or Array<Hash> batches
|
|
20
|
+
#
|
|
21
|
+
# This keeps batch construction on the Ruby side and creates one R data.frame
|
|
22
|
+
# from the merged column vectors, then converts it to Arrow Table.
|
|
23
|
+
#
|
|
24
|
+
# @param enum_or_array [Enumerable]
|
|
25
|
+
# @return [R::Object] Arrow Table handle in R
|
|
26
|
+
def self.from_ruby_batches(enum_or_array)
|
|
27
|
+
rows = []
|
|
28
|
+
enum_or_array.each do |batch|
|
|
29
|
+
if batch.is_a?(Hash)
|
|
30
|
+
rows << batch
|
|
31
|
+
elsif batch.respond_to?(:each)
|
|
32
|
+
batch.each do |row|
|
|
33
|
+
unless row.is_a?(Hash)
|
|
34
|
+
raise ArgumentError, 'each row must be a Hash'
|
|
35
|
+
end
|
|
36
|
+
rows << row
|
|
37
|
+
end
|
|
38
|
+
else
|
|
39
|
+
raise ArgumentError, 'batches must yield Hash rows or arrays of Hash rows'
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
raise ArgumentError, 'from_ruby_batches requires at least one row' if rows.empty?
|
|
44
|
+
|
|
45
|
+
keys = rows.flat_map(&:keys).map(&:to_s).uniq
|
|
46
|
+
columns = keys.each_with_object({}) { |k, h| h[k.to_sym] = [] }
|
|
47
|
+
|
|
48
|
+
rows.each do |row|
|
|
49
|
+
key_map = row.each_with_object({}) { |(k, v), h| h[k.to_s] = v }
|
|
50
|
+
keys.each { |k| columns[k.to_sym] << key_map[k] }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
df = R::Support.exec_function('data.frame', columns)
|
|
54
|
+
table_from(df)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Create an Arrow Table from an R data.frame (or tibble) handle.
|
|
58
|
+
# Uses arrow::as_arrow_table() on the R side.
|
|
59
|
+
#
|
|
60
|
+
# @param r_df [R::DataFrame, R::Object] an R-side data.frame/tibble handle
|
|
61
|
+
# @return [R::Object] handle to an Arrow Table in R
|
|
62
|
+
def self.table_from(r_df)
|
|
63
|
+
R.arrow___as_arrow_table(r_df)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Open a Parquet/Feather directory or file as an Arrow Dataset
|
|
67
|
+
# using arrow::open_dataset().
|
|
68
|
+
#
|
|
69
|
+
# @param path [String] file or directory path visible to R
|
|
70
|
+
# @return [R::Object] handle to an Arrow Dataset in R
|
|
71
|
+
def self.dataset(path)
|
|
72
|
+
R.arrow___open_dataset(path)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Read a Feather file into an R data.frame/tibble using read_feather().
|
|
76
|
+
#
|
|
77
|
+
# @param path [String]
|
|
78
|
+
# @return [R::DataFrame] Arrow-backed data.frame/tibble in R
|
|
79
|
+
def self.read_feather(path)
|
|
80
|
+
R.arrow___read_feather(path)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Write an R data.frame/tibble to a Feather file using write_feather().
|
|
84
|
+
#
|
|
85
|
+
# @param r_df [R::DataFrame, R::Object]
|
|
86
|
+
# @param path [String]
|
|
87
|
+
# @return [nil]
|
|
88
|
+
def self.write_feather(r_df, path)
|
|
89
|
+
R.arrow___write_feather(r_df, path)
|
|
90
|
+
nil
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Read a Parquet file into an R data.frame/tibble using read_parquet().
|
|
94
|
+
#
|
|
95
|
+
# @param path [String]
|
|
96
|
+
# @return [R::DataFrame] Arrow-backed data.frame/tibble in R
|
|
97
|
+
def self.read_parquet(path)
|
|
98
|
+
R.arrow___read_parquet(path)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Write an R data.frame/tibble to a Parquet file using write_parquet().
|
|
102
|
+
#
|
|
103
|
+
# @param r_df [R::DataFrame, R::Object]
|
|
104
|
+
# @param path [String]
|
|
105
|
+
# @return [nil]
|
|
106
|
+
def self.write_parquet(r_df, path)
|
|
107
|
+
R.arrow___write_parquet(r_df, path)
|
|
108
|
+
nil
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
data/lib/R_interface/r_libs.R
CHANGED
|
@@ -25,162 +25,49 @@ module R
|
|
|
25
25
|
|
|
26
26
|
module Support
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
# Galaaz 2.0: In the Shadow Bridge, these methods return
|
|
29
|
+
# the name of the R function as a string handle.
|
|
30
|
+
|
|
32
31
|
def self.capture
|
|
33
|
-
|
|
34
|
-
function(obj, ...) {
|
|
35
|
-
sink(tt <- textConnection("results","w"), split=FALSE, type = c("output", "message"));
|
|
36
|
-
print(obj, ...);
|
|
37
|
-
sink();
|
|
38
|
-
close(tt);
|
|
39
|
-
results
|
|
40
|
-
}
|
|
41
|
-
R
|
|
32
|
+
"capture" # Requires capture to be defined in R
|
|
42
33
|
end
|
|
43
34
|
|
|
44
35
|
def self.capture2
|
|
45
|
-
|
|
46
|
-
function(obj, ...) {
|
|
47
|
-
tryCatch({
|
|
48
|
-
sink(tt <- textConnection("results","w"), split=FALSE, type = c("output", "message"));
|
|
49
|
-
print(obj, ...);
|
|
50
|
-
sink();
|
|
51
|
-
results
|
|
52
|
-
}, finally = {
|
|
53
|
-
close(tt);
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
R
|
|
36
|
+
"capture2"
|
|
57
37
|
end
|
|
58
38
|
|
|
59
39
|
def self.start_capture
|
|
60
|
-
|
|
61
|
-
function(cap_variable) {
|
|
62
|
-
sink(con <- textConnection(cap_variable,"w"), split=FALSE, type = c("output"));
|
|
63
|
-
con
|
|
64
|
-
}
|
|
65
|
-
R
|
|
40
|
+
"start_capture"
|
|
66
41
|
end
|
|
67
42
|
|
|
68
43
|
def self.stop_capture
|
|
69
|
-
|
|
70
|
-
function(con) {
|
|
71
|
-
sink();
|
|
72
|
-
close(con);
|
|
73
|
-
}
|
|
74
|
-
R
|
|
44
|
+
"stop_capture"
|
|
75
45
|
end
|
|
76
46
|
|
|
77
|
-
#--------------------------------------------------------------------------------------
|
|
78
|
-
#
|
|
79
|
-
#--------------------------------------------------------------------------------------
|
|
80
|
-
|
|
81
47
|
def self.dbk_index
|
|
82
|
-
|
|
83
|
-
function(obj, ...) {
|
|
84
|
-
obj[[...]]
|
|
85
|
-
}
|
|
86
|
-
R
|
|
48
|
+
"`[[`"
|
|
87
49
|
end
|
|
88
50
|
|
|
89
|
-
#--------------------------------------------------------------------------------------
|
|
90
|
-
# multi-dimensional indexing
|
|
91
|
-
#--------------------------------------------------------------------------------------
|
|
92
|
-
|
|
93
51
|
def self.md_index
|
|
94
|
-
|
|
95
|
-
function(mdobject, ...) {
|
|
96
|
-
mdobject[...];
|
|
97
|
-
}
|
|
98
|
-
R
|
|
52
|
+
"`[`"
|
|
99
53
|
end
|
|
100
54
|
|
|
101
|
-
#--------------------------------------------------------------------------------------
|
|
102
|
-
# R function that returns another R function that calls back a Ruby Method or Proc
|
|
103
|
-
# Some R functions that receive a function as argument will test to see if their
|
|
104
|
-
# parameters is a function or a symbol, so the Ruby method needs to be wrapped inside
|
|
105
|
-
# an R function in order for it to pass this test.
|
|
106
|
-
#--------------------------------------------------------------------------------------
|
|
107
|
-
|
|
108
55
|
def self.ruby_callback_method
|
|
109
|
-
|
|
110
|
-
function(rb_method) {
|
|
111
|
-
function(...) {
|
|
112
|
-
rb_method(...)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
R
|
|
56
|
+
"ruby_callback_method"
|
|
116
57
|
end
|
|
117
|
-
|
|
118
|
-
#--------------------------------------------------------------------------------------
|
|
119
|
-
#
|
|
120
|
-
#--------------------------------------------------------------------------------------
|
|
121
58
|
|
|
122
59
|
def self.enquo
|
|
123
|
-
|
|
124
|
-
function(x, ...) {
|
|
125
|
-
enquo(x)
|
|
126
|
-
}
|
|
127
|
-
R
|
|
60
|
+
"enquo"
|
|
128
61
|
end
|
|
129
62
|
|
|
130
|
-
#--------------------------------------------------------------------------------------
|
|
131
|
-
#
|
|
132
|
-
#--------------------------------------------------------------------------------------
|
|
133
|
-
|
|
134
63
|
def self.range
|
|
135
|
-
|
|
136
|
-
function(x, y, neg = FALSE) {
|
|
137
|
-
e1 = enexpr(x)
|
|
138
|
-
e2 = enexpr(y)
|
|
139
|
-
if (neg) {
|
|
140
|
-
expr(-(!!e1:!!e2))
|
|
141
|
-
} else {
|
|
142
|
-
expr(!!e1:!!e2)
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
R
|
|
64
|
+
"range_helper"
|
|
146
65
|
end
|
|
147
66
|
|
|
148
|
-
#--------------------------------------------------------------------------------------
|
|
149
|
-
#
|
|
150
|
-
#--------------------------------------------------------------------------------------
|
|
151
|
-
|
|
152
67
|
def self.create_bin_expr(operator)
|
|
153
|
-
|
|
154
|
-
Polyglot.eval("R", <<-R)
|
|
155
|
-
function(op1, op2) {
|
|
156
|
-
o1 = enexpr(op1)
|
|
157
|
-
o2 = enexpr(op2)
|
|
158
|
-
if (typeof(o1) == 'symbol' && o1 == expr(`__`)) {
|
|
159
|
-
o1 = expr(.)
|
|
160
|
-
}
|
|
161
|
-
if (typeof(o2) == 'symbol' && o2 == expr(`__`)) {
|
|
162
|
-
o2 = expr(.)
|
|
163
|
-
}
|
|
164
|
-
exp = expr(#{operator}(!!o1, !!o2))
|
|
165
|
-
if (#{is_formula}) {
|
|
166
|
-
as.formula(exp)
|
|
167
|
-
} else {
|
|
168
|
-
exp
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
R
|
|
68
|
+
"function(op1, op2) { #{operator}(op1, op2) }"
|
|
172
69
|
end
|
|
173
70
|
|
|
174
|
-
#--------------------------------------------------------------------------------------
|
|
175
|
-
#
|
|
176
|
-
#--------------------------------------------------------------------------------------
|
|
177
|
-
|
|
178
|
-
Polyglot.eval("R", <<-R)
|
|
179
|
-
plot = function(...) {
|
|
180
|
-
print("Function 'plot' is not implemented in fastR. Please, use ggplot instead")
|
|
181
|
-
}
|
|
182
|
-
R
|
|
183
|
-
|
|
184
71
|
end
|
|
185
72
|
|
|
186
73
|
end
|
|
File without changes
|
|
@@ -34,7 +34,15 @@ module R
|
|
|
34
34
|
#--------------------------------------------------------------------------------------
|
|
35
35
|
|
|
36
36
|
def exec_bin_oper(operator, other_object)
|
|
37
|
-
|
|
37
|
+
# Use infix notation: lhs operator rhs
|
|
38
|
+
# We need to strip backticks from operator if present
|
|
39
|
+
op = operator.delete("`")
|
|
40
|
+
|
|
41
|
+
var_name = R::Support.generate_var_name
|
|
42
|
+
rhs = R::Support.parse_arg(other_object)
|
|
43
|
+
|
|
44
|
+
R.bridge.eval_r("#{var_name} <- #{@r_interop} #{op} #{rhs}")
|
|
45
|
+
R::Object.build(var_name)
|
|
38
46
|
end
|
|
39
47
|
|
|
40
48
|
#--------------------------------------------------------------------------------------
|
|
@@ -135,6 +143,8 @@ module R
|
|
|
135
143
|
exec_bin_oper("`==`", other_object)
|
|
136
144
|
end
|
|
137
145
|
|
|
146
|
+
alias_method :eql, :eq
|
|
147
|
+
|
|
138
148
|
#--------------------------------------------------------------------------------------
|
|
139
149
|
#
|
|
140
150
|
#--------------------------------------------------------------------------------------
|
|
@@ -191,10 +201,18 @@ module R
|
|
|
191
201
|
|
|
192
202
|
def til(other_object)
|
|
193
203
|
return R::Support.exec_function_name("`~`", other_object) if
|
|
194
|
-
((self.is_a?
|
|
204
|
+
((self.is_a?(Symbol) && (self == :all)) ||
|
|
205
|
+
(self.is_a?(R::SymbolRef) && self.to_r_symbol == "all"))
|
|
195
206
|
exec_bin_oper("`~`", other_object)
|
|
196
207
|
end
|
|
197
208
|
|
|
209
|
+
def _(op, other_object)
|
|
210
|
+
operator = op.to_s.gsub(/__/,".")
|
|
211
|
+
# If it's a standard letter-based operator like 'in', wrap in %
|
|
212
|
+
operator = "%#{operator}%" if operator =~ /^[a-zA-Z.]+$/
|
|
213
|
+
exec_bin_oper(operator, other_object)
|
|
214
|
+
end
|
|
215
|
+
|
|
198
216
|
end
|
|
199
217
|
|
|
200
218
|
end
|
data/lib/R_interface/rclosure.rb
CHANGED
|
@@ -25,12 +25,16 @@ module R
|
|
|
25
25
|
|
|
26
26
|
class Closure < Object
|
|
27
27
|
|
|
28
|
+
def class
|
|
29
|
+
::R::Closure
|
|
30
|
+
end
|
|
31
|
+
|
|
28
32
|
#----------------------------------------------------------------------------------------
|
|
29
33
|
#
|
|
30
34
|
#----------------------------------------------------------------------------------------
|
|
31
35
|
|
|
32
36
|
def call(*args)
|
|
33
|
-
R::Support.exec_function(@r_interop, *args)
|
|
37
|
+
::R::Support.exec_function(@r_interop, *args)
|
|
34
38
|
end
|
|
35
39
|
|
|
36
40
|
end
|