galaaz 0.5.0 → 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 +1360 -636
- data/Rakefile +61 -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 +84 -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 +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 +115 -155
- 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 +47 -52
- data/blogs/gknit/gknit.md +1430 -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 +852 -239
- data/blogs/manual/manual.log +1786 -0
- data/blogs/manual/manual.md +1360 -636
- 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-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 +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 +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/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 +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 +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 +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 +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 +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 +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 +194 -64
- 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
|
@@ -1,102 +1,66 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
##########################################################################################
|
|
4
|
-
# @author Rodrigo Botafogo
|
|
5
|
-
#
|
|
6
|
-
# Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
|
7
|
-
# and distribute this software and its documentation, without fee and without a signed
|
|
8
|
-
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
|
9
|
-
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
|
10
|
-
# distributions.
|
|
11
|
-
#
|
|
12
|
-
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
|
13
|
-
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
|
14
|
-
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
|
15
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
|
16
|
-
#
|
|
17
|
-
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
18
|
-
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
|
19
|
-
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
|
20
|
-
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
|
21
|
-
# OR MODIFICATIONS.
|
|
22
|
-
##########################################################################################
|
|
23
|
-
|
|
1
|
+
# rdata_frame.rb
|
|
24
2
|
module R
|
|
25
|
-
|
|
26
3
|
class DataFrame < Object
|
|
27
4
|
include IndexedObject
|
|
28
5
|
include MDIndexedObject
|
|
29
6
|
|
|
30
|
-
|
|
31
|
-
#
|
|
32
|
-
|
|
7
|
+
# Phase 5.2: unbox entire data.frame via NewBridgeAdapter#pull_dataframe.
|
|
8
|
+
# This avoids the generic list-unboxing path which relies on scalar-only eval.
|
|
9
|
+
def unboxed_get(index = nil, depth = 0)
|
|
10
|
+
return ::R.bridge.pull_dataframe(@r_interop) if index.nil?
|
|
11
|
+
if index.is_a?(::Integer)
|
|
12
|
+
# For scalar-like data.frame views (e.g. Arrow/dplyr collect slices), treat
|
|
13
|
+
# [[i]] as list-column extraction and keep unboxing in Ruby side.
|
|
14
|
+
val = ::R::Support.eval("#{@r_interop}[[#{index + 1}]]")
|
|
15
|
+
return val unless val.is_a?(::R::Object)
|
|
16
|
+
return val.unboxed_get(nil, depth + 1)
|
|
17
|
+
end
|
|
18
|
+
super
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def class
|
|
22
|
+
::R::DataFrame
|
|
23
|
+
end
|
|
33
24
|
|
|
34
25
|
def qplot(*args)
|
|
35
|
-
print R
|
|
26
|
+
# Use R's print so the plot is displayed on the R device with a single argument (avoids "invalid printing digits" from extra args).
|
|
27
|
+
::R.print(::R.qplot(*args, data: self))
|
|
36
28
|
end
|
|
37
29
|
|
|
38
|
-
#--------------------------------------------------------------------------------------
|
|
39
|
-
#
|
|
40
|
-
#--------------------------------------------------------------------------------------
|
|
41
|
-
|
|
42
30
|
def method_missing_assign(column_name, arg)
|
|
43
|
-
|
|
31
|
+
# Functional form: df <- `[[<-`(df, i = 'col', value = val)
|
|
32
|
+
res = ::R::Support.exec_function("`[[<-`", self, i: column_name, value: arg)
|
|
33
|
+
@r_interop = res.r_interop
|
|
34
|
+
res
|
|
44
35
|
end
|
|
45
36
|
|
|
46
|
-
#--------------------------------------------------------------------------------------
|
|
47
|
-
# subset assign a vector with an index to a value
|
|
48
|
-
# @param index [Array] The vector index
|
|
49
|
-
# @param values [R::Object] The values to assign to the index. Note that
|
|
50
|
-
# index can span multiple
|
|
51
|
-
# values, for ex., R.c(2, 3, 5)
|
|
52
|
-
#--------------------------------------------------------------------------------------
|
|
53
|
-
|
|
54
37
|
def []=(index, *args)
|
|
55
38
|
values = args[-1]
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
# dealing with double indexing function '[['
|
|
59
|
-
if (index.is_a? Array)
|
|
60
|
-
setR_name("`[[<-`", R.empty_symbol, *index, values)
|
|
39
|
+
res = if index.is_a? ::Array
|
|
40
|
+
::R::Support.exec_function("`[[<-`", self, i: index, value: values)
|
|
61
41
|
else
|
|
62
|
-
idx2
|
|
63
|
-
|
|
42
|
+
idx2 = (args.size > 1) ? args[-2] : nil
|
|
43
|
+
if idx2
|
|
44
|
+
::R::Support.exec_function("`[<-`", self, i: index, j: idx2, value: values)
|
|
45
|
+
else
|
|
46
|
+
::R::Support.exec_function("`[<-`", self, i: index, value: values)
|
|
47
|
+
end
|
|
64
48
|
end
|
|
65
|
-
|
|
49
|
+
@r_interop = res.r_interop
|
|
66
50
|
self
|
|
67
|
-
|
|
68
51
|
end
|
|
69
|
-
|
|
70
|
-
#--------------------------------------------------------------------------------------
|
|
71
|
-
# Goes through each row of the dataframe and return the whole row as the first element
|
|
72
|
-
# and the row name (Ruby string) as the second
|
|
73
|
-
#--------------------------------------------------------------------------------------
|
|
74
52
|
|
|
53
|
+
|
|
75
54
|
def each_row
|
|
76
|
-
|
|
77
|
-
# nrow is the R function that return the number of rows in the dataset. This
|
|
78
|
-
# function returns a R::Vector, so we need to extract its first element (<< 0)
|
|
79
55
|
(1..nrow >> 0).each do |i|
|
|
80
56
|
yield self[i, :all], self.rownames[i] >> 0
|
|
81
57
|
end
|
|
82
|
-
|
|
83
58
|
end
|
|
84
59
|
|
|
85
|
-
#--------------------------------------------------------------------------------------
|
|
86
|
-
# Goes through each column of the dataframe and return the whole column as the first
|
|
87
|
-
# element and the column name (Ruby string) as the second
|
|
88
|
-
#--------------------------------------------------------------------------------------
|
|
89
|
-
|
|
90
60
|
def each_column
|
|
91
|
-
|
|
92
|
-
# ncol is the R function that return the number of columns in the dataset. This
|
|
93
|
-
# function returns a R::Vector, so we need to extract its first element (<< 0)
|
|
94
61
|
(1..ncol >> 0).each do |i|
|
|
95
62
|
yield self[:all, i], self.names[i] >> 0
|
|
96
63
|
end
|
|
97
|
-
|
|
98
64
|
end
|
|
99
|
-
|
|
100
65
|
end
|
|
101
|
-
|
|
102
66
|
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# R::Device: Ruby wrapper for Galaaz plot devices (png, svg, etc.).
|
|
3
|
+
# Uses base R graphics and evaluate::plot_snapshot; no R package "device" required.
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
|
|
7
|
+
module R
|
|
8
|
+
class Device
|
|
9
|
+
def ensure_plot_helpers!
|
|
10
|
+
R.bridge.eval_r(<<~RCODE)
|
|
11
|
+
if (!exists("evaluate_plot_snapshot", envir = .GlobalEnv, inherits = FALSE)) {
|
|
12
|
+
.GlobalEnv$evaluate_plot_snapshot <- function() {
|
|
13
|
+
grDevices::recordPlot()
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (!exists("galaaz_save_plot", envir = .GlobalEnv, inherits = FALSE)) {
|
|
17
|
+
.GlobalEnv$galaaz_save_plot <- function(path, dev_type, width, height, dpi) {
|
|
18
|
+
if (dev_type == "png") {
|
|
19
|
+
do.call(grDevices::dev.copy, list(
|
|
20
|
+
device = grDevices::png,
|
|
21
|
+
filename = path,
|
|
22
|
+
width = width,
|
|
23
|
+
height = height,
|
|
24
|
+
units = "in",
|
|
25
|
+
res = dpi
|
|
26
|
+
))
|
|
27
|
+
} else if (dev_type == "svg") {
|
|
28
|
+
do.call(grDevices::dev.copy, list(
|
|
29
|
+
device = grDevices::svg,
|
|
30
|
+
filename = path,
|
|
31
|
+
width = width,
|
|
32
|
+
height = height
|
|
33
|
+
))
|
|
34
|
+
} else if (dev_type == "pdf") {
|
|
35
|
+
do.call(grDevices::dev.copy, list(
|
|
36
|
+
device = grDevices::pdf,
|
|
37
|
+
file = path,
|
|
38
|
+
width = width,
|
|
39
|
+
height = height
|
|
40
|
+
))
|
|
41
|
+
} else {
|
|
42
|
+
stop(paste("unsupported dev_type:", dev_type))
|
|
43
|
+
}
|
|
44
|
+
grDevices::dev.off()
|
|
45
|
+
path
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
invisible(NULL)
|
|
49
|
+
RCODE
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def initialize(type, width: 480, height: 480, dpi: 72, record: true, &block)
|
|
53
|
+
@type = type.to_s
|
|
54
|
+
@width = width
|
|
55
|
+
@height = height
|
|
56
|
+
@dpi = dpi
|
|
57
|
+
@record = record
|
|
58
|
+
@block = block
|
|
59
|
+
@dev_path = nil
|
|
60
|
+
@opened = false
|
|
61
|
+
@last_save_target = nil
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def open
|
|
65
|
+
return if @opened
|
|
66
|
+
dir = File.join(Dir.tmpdir, "galaaz_device_#{Process.pid}")
|
|
67
|
+
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
|
68
|
+
@dev_path = File.join(dir, "dev_#{object_id}.#{@type == 'svg' ? 'svg' : 'png'}")
|
|
69
|
+
w_px = (@width * @dpi).to_i
|
|
70
|
+
h_px = (@height * @dpi).to_i
|
|
71
|
+
if @type == 'svg'
|
|
72
|
+
R.bridge.eval_r("svg('#{@dev_path.gsub("'", "\\\\'")}', width = #{@width}, height = #{@height})")
|
|
73
|
+
else
|
|
74
|
+
R.bridge.eval_r("png('#{@dev_path.gsub("'", "\\\\'")}', width = #{w_px}, height = #{h_px}, res = #{@dpi})")
|
|
75
|
+
end
|
|
76
|
+
@opened = true
|
|
77
|
+
yield if block_given?
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def close
|
|
81
|
+
return unless @opened
|
|
82
|
+
R.dev__off
|
|
83
|
+
@opened = false
|
|
84
|
+
if @last_save_target && @dev_path && File.exist?(@dev_path)
|
|
85
|
+
FileUtils.cp(@dev_path, @last_save_target)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def plot_snapshot
|
|
90
|
+
ensure_plot_helpers!
|
|
91
|
+
R.evaluate_plot_snapshot
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def save_plot(plot, name, dev_type, width, height, ext, dpi)
|
|
95
|
+
out_name = "#{name}.#{ext}"
|
|
96
|
+
target = out_name.start_with?('/') ? out_name : File.join(Dir.pwd, out_name)
|
|
97
|
+
if @opened
|
|
98
|
+
# Persist current page and reopen the device to keep plotting.
|
|
99
|
+
R.dev__off
|
|
100
|
+
@opened = false
|
|
101
|
+
if @dev_path && File.exist?(@dev_path) && File.size(@dev_path).to_i > 0
|
|
102
|
+
FileUtils.cp(@dev_path, target)
|
|
103
|
+
end
|
|
104
|
+
open
|
|
105
|
+
@last_save_target = nil
|
|
106
|
+
elsif !@opened && @dev_path && File.exist?(@dev_path) && File.size(@dev_path).to_i > 0
|
|
107
|
+
@last_save_target = target
|
|
108
|
+
FileUtils.cp(@dev_path, target)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
out_name
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def self.new(type, width: 480, height: 480, dpi: 72, record: true, &block)
|
|
115
|
+
inst = allocate
|
|
116
|
+
inst.send(:initialize, type, width: width, height: height, dpi: dpi, record: record, &block)
|
|
117
|
+
if block_given?
|
|
118
|
+
inst.open
|
|
119
|
+
block.call
|
|
120
|
+
inst.close
|
|
121
|
+
end
|
|
122
|
+
inst
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
data/lib/R_interface/rdevices.R
CHANGED
|
File without changes
|
|
@@ -30,12 +30,16 @@ module R
|
|
|
30
30
|
class Environment < Object
|
|
31
31
|
include IndexedObject
|
|
32
32
|
|
|
33
|
+
def class
|
|
34
|
+
::R::Environment
|
|
35
|
+
end
|
|
36
|
+
|
|
33
37
|
#--------------------------------------------------------------------------------------
|
|
34
38
|
#
|
|
35
39
|
#--------------------------------------------------------------------------------------
|
|
36
40
|
|
|
37
41
|
def set(key, value)
|
|
38
|
-
R.assign(key.to_s, value, pos: self)
|
|
42
|
+
::R.assign(key.to_s, value, pos: self)
|
|
39
43
|
end
|
|
40
44
|
|
|
41
45
|
#--------------------------------------------------------------------------------------
|
|
@@ -43,7 +47,7 @@ module R
|
|
|
43
47
|
#--------------------------------------------------------------------------------------
|
|
44
48
|
|
|
45
49
|
def get(key)
|
|
46
|
-
R.get(key.to_s, pos: self)
|
|
50
|
+
::R.get(key.to_s, pos: self)
|
|
47
51
|
end
|
|
48
52
|
|
|
49
53
|
#--------------------------------------------------------------------------------------
|
|
@@ -51,12 +55,14 @@ module R
|
|
|
51
55
|
#--------------------------------------------------------------------------------------
|
|
52
56
|
|
|
53
57
|
def method_missing(symbol, *args, &block)
|
|
54
|
-
|
|
55
|
-
name = R::Support.convert_symbol2r(symbol)
|
|
58
|
+
name = ::R::Support.convert_symbol2r(symbol)
|
|
56
59
|
|
|
57
60
|
case
|
|
58
61
|
when name =~ /(.*)=$/
|
|
59
62
|
set($1, args[0])
|
|
63
|
+
when name == "env_names"
|
|
64
|
+
# Call R's env_names(env) from Environment so .length is vector length (1), not string length.
|
|
65
|
+
::R::Support.exec_function("env_names", self, unbox: false)
|
|
60
66
|
else
|
|
61
67
|
super(symbol, *args, &block)
|
|
62
68
|
end
|
|
@@ -28,7 +28,11 @@ module R
|
|
|
28
28
|
#--------------------------------------------------------------------------------------
|
|
29
29
|
|
|
30
30
|
class RExpression < Object
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
def class
|
|
33
|
+
::R::RExpression
|
|
34
|
+
end
|
|
35
|
+
|
|
32
36
|
#--------------------------------------------------------------------------------------
|
|
33
37
|
# Builds
|
|
34
38
|
#--------------------------------------------------------------------------------------
|
|
@@ -34,14 +34,38 @@ module R
|
|
|
34
34
|
# @param index [Array] The vector index.
|
|
35
35
|
#--------------------------------------------------------------------------------------
|
|
36
36
|
|
|
37
|
-
def [](index)
|
|
38
|
-
|
|
37
|
+
def [](*index)
|
|
39
38
|
# dealing with double indexing function '[['
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
# If we have multiple indices, or a single array index, use [[ or `[` for names
|
|
40
|
+
if (index.size > 1) || (index[0].is_a? Array)
|
|
41
|
+
args = (index.size > 1) ? index : index[0]
|
|
42
|
+
# For DataFrame with two indices: R's [[i,j]] is row i, col j. R's [[ does not accept character indices; use `[` for row/col names.
|
|
43
|
+
# When any index is :all, use `[` (single bracket) so R gets m[i,] or m[,j]; `[[` does not accept missing subscript.
|
|
44
|
+
# When any index is an R object (e.g. vector), use `[`; `[[` only selects one element ("attempt to select more than one element").
|
|
45
|
+
use_md = (args.size == 2 && self.is_a?(::R::DataFrame) && (args[0].is_a?(::String) || args[0].is_a?(::Symbol) || args[1].is_a?(::String) || args[1].is_a?(::Symbol))) ||
|
|
46
|
+
(args.size == 2 && (args[0] == :all || args[1] == :all)) ||
|
|
47
|
+
(args.size == 2 && (args[0].is_a?(::R::Object) || args[1].is_a?(::R::Object)))
|
|
48
|
+
if use_md
|
|
49
|
+
::R::Support.exec_function(::R::Support.md_index, self, *args)
|
|
50
|
+
else
|
|
51
|
+
::R::Support.exec_function(::R::Support.dbk_index, self, *args)
|
|
52
|
+
end
|
|
42
53
|
else
|
|
43
|
-
R::
|
|
54
|
+
if self.is_a?(::R::DataFrame) && index.size == 1 &&
|
|
55
|
+
(index[0].is_a?(::R::Language) || index[0].is_a?(::R::Object))
|
|
56
|
+
# For data.frame, a single logical/language index is expected to filter rows.
|
|
57
|
+
# Evaluate language conditions in data-frame context, then subset df[cond, ].
|
|
58
|
+
row_filter = index[0].is_a?(::R::Language) ? ::R::Support.exec_function("with", self, index[0]) : index[0]
|
|
59
|
+
::R::Support.exec_function(::R::Support.md_index, self, row_filter, :all)
|
|
60
|
+
else
|
|
61
|
+
::R::Support.exec_function_name("`[`", self, *index)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
rescue ::RuntimeError => e
|
|
65
|
+
if e.message.to_s.include?("incorrect number of subscripts")
|
|
66
|
+
::Kernel.raise(::ArgumentError, e.message)
|
|
44
67
|
end
|
|
68
|
+
::Kernel.raise(e)
|
|
45
69
|
end
|
|
46
70
|
|
|
47
71
|
#--------------------------------------------------------------------------------------
|
|
@@ -52,17 +76,21 @@ module R
|
|
|
52
76
|
# values, for ex., R.c(2, 3, 5)
|
|
53
77
|
#--------------------------------------------------------------------------------------
|
|
54
78
|
|
|
55
|
-
def []=(
|
|
79
|
+
def []=(*args)
|
|
80
|
+
values = args.pop
|
|
81
|
+
index = args
|
|
56
82
|
|
|
57
|
-
#
|
|
58
|
-
if (index.is_a? Array)
|
|
59
|
-
|
|
83
|
+
# Assign result back to same handle so the object is updated in place (R's x[i] <- v semantics)
|
|
84
|
+
if (index.size > 1) || (index[0].is_a? Array)
|
|
85
|
+
all_args = [@r_interop, *index, values].map { |a| ::R::Support.parse_arg(a) }.join(", ")
|
|
86
|
+
::R.bridge.eval_r("#{@r_interop} <- `[[<-`(#{all_args})")
|
|
60
87
|
else
|
|
61
|
-
|
|
88
|
+
idx_r = ::R::Support.parse_arg(index[0])
|
|
89
|
+
vals_r = ::R::Support.parse_arg(values)
|
|
90
|
+
::R.bridge.eval_r("#{@r_interop} <- `[<-`(#{@r_interop}, #{idx_r}, #{vals_r})")
|
|
62
91
|
end
|
|
63
|
-
|
|
92
|
+
|
|
64
93
|
self
|
|
65
|
-
|
|
66
94
|
end
|
|
67
95
|
|
|
68
96
|
#--------------------------------------------------------------------------------------
|
|
@@ -70,7 +98,7 @@ module R
|
|
|
70
98
|
#--------------------------------------------------------------------------------------
|
|
71
99
|
|
|
72
100
|
def size
|
|
73
|
-
length
|
|
101
|
+
length.unboxed_get(0)
|
|
74
102
|
end
|
|
75
103
|
|
|
76
104
|
end
|
|
@@ -1,80 +1,38 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
##########################################################################################
|
|
4
|
-
# @author Rodrigo Botafogo
|
|
5
|
-
#
|
|
6
|
-
# Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
|
7
|
-
# and distribute this software and its documentation, without fee and without a signed
|
|
8
|
-
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
|
9
|
-
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
|
10
|
-
# distributions.
|
|
11
|
-
#
|
|
12
|
-
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
|
13
|
-
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
|
14
|
-
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
|
15
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
|
16
|
-
#
|
|
17
|
-
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
18
|
-
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
|
19
|
-
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
|
20
|
-
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
|
21
|
-
# OR MODIFICATIONS.
|
|
22
|
-
##########################################################################################
|
|
23
|
-
|
|
1
|
+
# rlanguage.rb
|
|
24
2
|
module R
|
|
25
|
-
|
|
26
3
|
class Language < Object
|
|
27
4
|
include BinaryOperators
|
|
28
5
|
include LogicalOperators
|
|
29
6
|
include ExpBinOp
|
|
30
7
|
include IndexedObject
|
|
31
8
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
#--------------------------------------------------------------------------------------
|
|
35
|
-
#
|
|
36
|
-
#--------------------------------------------------------------------------------------
|
|
37
|
-
|
|
38
|
-
def self.to_expression(obj)
|
|
39
|
-
obj.respond_to?(:expression) ? obj.expression : obj.to_s
|
|
9
|
+
def class
|
|
10
|
+
::R::Language
|
|
40
11
|
end
|
|
41
|
-
|
|
42
|
-
#--------------------------------------------------------------------------------------
|
|
43
|
-
# Builds a call functions with the given arguments.
|
|
44
|
-
# @param function_name [String] name of the function to apply: ex: '+'
|
|
45
|
-
# @param args [Array] two elements array for the binary function: ex [:a, :b]
|
|
46
|
-
# @return call expression. With the above paramenters the result would be:
|
|
47
|
-
# .Primitive("+")(a, b)
|
|
48
|
-
#--------------------------------------------------------------------------------------
|
|
49
12
|
|
|
13
|
+
attr_accessor :expression
|
|
14
|
+
|
|
50
15
|
def self.build(function_name, *args)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
16
|
+
# function_name is something like '`+`' or '`~`'
|
|
17
|
+
op = function_name.delete("`").strip
|
|
18
|
+
lhs = ::R::Support.parse_arg(args[0])
|
|
19
|
+
rhs = ::R::Support.parse_arg(args[1])
|
|
20
|
+
r_expr = (op == ":") ? "#{lhs}#{op}#{rhs}" : "#{lhs} #{op} #{rhs}"
|
|
21
|
+
lhs_display = ::R::Support.expression_display_arg(args[0])
|
|
22
|
+
rhs_display = ::R::Support.expression_display_arg(args[1])
|
|
23
|
+
expr_display = (op == ":") ? "#{lhs_display}#{op}#{rhs_display}" : "#{lhs_display} #{op} #{rhs_display}"
|
|
24
|
+
res = ::R::Language.allocate
|
|
25
|
+
res.instance_variable_set(:@r_interop, r_expr)
|
|
26
|
+
res.expression = expr_display
|
|
58
27
|
res
|
|
59
|
-
|
|
60
28
|
end
|
|
61
29
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
#--------------------------------------------------------------------------------------
|
|
65
|
-
|
|
66
|
-
def assign(expression)
|
|
67
|
-
exec_bin_oper("`<-`", expression).eval
|
|
30
|
+
def i
|
|
31
|
+
"I(#{expression})"
|
|
68
32
|
end
|
|
69
|
-
|
|
70
|
-
#--------------------------------------------------------------------------------------
|
|
71
|
-
#
|
|
72
|
-
#--------------------------------------------------------------------------------------
|
|
73
33
|
|
|
74
|
-
def
|
|
75
|
-
|
|
34
|
+
def to_s
|
|
35
|
+
expression || super
|
|
76
36
|
end
|
|
77
|
-
|
|
78
37
|
end
|
|
79
|
-
|
|
80
38
|
end
|