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
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/specs/r_dataframe.spec.rb
DELETED
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
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
|
-
|
|
24
|
-
require 'galaaz'
|
|
25
|
-
|
|
26
|
-
describe R::DataFrame do
|
|
27
|
-
|
|
28
|
-
#----------------------------------------------------------------------------------------
|
|
29
|
-
context "Create DataFrame" do
|
|
30
|
-
|
|
31
|
-
it "should create a dataframe from a vector" do
|
|
32
|
-
vec = R.seq(6)
|
|
33
|
-
vec.dim = R.c(2, 3)
|
|
34
|
-
|
|
35
|
-
# create a DataFrame from a vector
|
|
36
|
-
df = vec.as__data__frame
|
|
37
|
-
expect(df[1, "V1"]).to eq 1
|
|
38
|
-
expect(df[1, 'V2']).to eq 3
|
|
39
|
-
# When you extract a single row from a data frame you get a one-row data frame.
|
|
40
|
-
# Convert it to a numeric vector with 'as__numeric'
|
|
41
|
-
expect(df[1, :all].as__numeric).to eq R.c(1.0, 3, 5)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
#----------------------------------------------------------------------------------------
|
|
47
|
-
context "Subsetting" do
|
|
48
|
-
|
|
49
|
-
it "should do integer subsetting" do
|
|
50
|
-
grades = R.c(1.0, 2.0, 2.0, 3.0, 1.0)
|
|
51
|
-
|
|
52
|
-
info = R.data__frame(
|
|
53
|
-
grade: (3..1),
|
|
54
|
-
desc: R.c("Excellent", "Good", "Poor"),
|
|
55
|
-
fail: R.c(false, false, true)
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
id = R.match(grades, info.grade)
|
|
59
|
-
table = info[id, :all]
|
|
60
|
-
|
|
61
|
-
expect(table.grade[1]).to eq 1
|
|
62
|
-
expect(table.desc.levels[2]).to eq "Good"
|
|
63
|
-
expect(table.fail[4]).to eq false
|
|
64
|
-
|
|
65
|
-
info.rownames = info.grade
|
|
66
|
-
table2 = info[grades.as__character, :all]
|
|
67
|
-
|
|
68
|
-
expect(table2.grade[2]).to eq 2
|
|
69
|
-
expect(table2.desc.levels[1]).to eq "Excellent"
|
|
70
|
-
expect(table2.fail[4]).to eq true
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
#----------------------------------------------------------------------------------------
|
|
77
|
-
context "Subsetting with '['" do
|
|
78
|
-
|
|
79
|
-
before(:each) do
|
|
80
|
-
@mtcars = ~:mtcars
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "should subset with [ with only the column index" do
|
|
84
|
-
slice = @mtcars[1]
|
|
85
|
-
expect(slice.typeof).to eq "list"
|
|
86
|
-
expect(slice.rclass).to eq "data.frame"
|
|
87
|
-
expect(slice.length).to eq 1
|
|
88
|
-
expect(slice[[1]][1]).to eq 21.0
|
|
89
|
-
expect(slice[[1, 1]]).to eq 21.0
|
|
90
|
-
# undefined columns selected (RError)
|
|
91
|
-
expect { slice['Mazda RX4'] }.to raise_error(RuntimeError)
|
|
92
|
-
expect(slice[['Mazda RX4']]).to eq nil
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it "should subset with [ with a column range" do
|
|
96
|
-
slice = @mtcars[(1..3)]
|
|
97
|
-
expect(slice.typeof).to eq "list"
|
|
98
|
-
expect(slice.rclass).to eq "data.frame"
|
|
99
|
-
expect(slice.length).to eq 3
|
|
100
|
-
expect(slice[[2]][10]).to eq 6.0
|
|
101
|
-
expect(slice[10, 2]).to eq 6.0
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it "should subset with [ by row and column indices" do
|
|
105
|
-
expect(@mtcars[1, 1]).to eq 21.0
|
|
106
|
-
expect(@mtcars[6, 5]).to eq 2.76
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
it "do not use R style missing value idexing with [" do
|
|
110
|
-
# This array bellow is equivalent to [6]. This can bring some surprises for
|
|
111
|
-
# R people that are used to this indexing notation, as in this case the ','
|
|
112
|
-
# is ignored
|
|
113
|
-
arr = [6, ]
|
|
114
|
-
expect(arr).to eq [6]
|
|
115
|
-
|
|
116
|
-
# This will output the sixth column of the mtcars dataframe
|
|
117
|
-
slice = @mtcars[6, ]
|
|
118
|
-
expect(slice.typeof).to eq "list"
|
|
119
|
-
expect(slice.rclass).to eq "data.frame"
|
|
120
|
-
expect(slice.length).to eq 1
|
|
121
|
-
expect(slice[[1]][1]).to eq 2.62
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
it "should subset with [ by row index and :all" do
|
|
125
|
-
# Hornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2
|
|
126
|
-
slice = @mtcars[5, :all]
|
|
127
|
-
expect(slice.rclass).to eq "data.frame"
|
|
128
|
-
expect(slice[1, 1]).to eq 18.7
|
|
129
|
-
expect(slice[1, 1]).not_to eq 360.0
|
|
130
|
-
expect(slice.names).to eq R.c("mpg", "cyl", "disp", "hp", "drat",
|
|
131
|
-
"wt", "qsec", "vs", "am", "gear", "carb")
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
it "should subset with [ by row index, :all and allowing for drop parameter" do
|
|
135
|
-
# will transform the data into a list
|
|
136
|
-
lst = @mtcars[1, :all, drop: true]
|
|
137
|
-
expect(lst.typeof).to eq "list"
|
|
138
|
-
expect(lst[[1]]).to eq 21.0
|
|
139
|
-
expect(lst[1]).to eq R.list(mpg: 21.0)
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
it "should subset with [ by :all and column index" do
|
|
143
|
-
# [1] 110 110 93 110 175 105 245 62 95 123 123 180 180 180 205 215 230 66 52
|
|
144
|
-
# [20] 65 97 150 150 245 175 66 91 113 264 175 335 109
|
|
145
|
-
slice = @mtcars[:all, 4]
|
|
146
|
-
expect(slice.rclass).to eq "numeric"
|
|
147
|
-
expect(slice.typeof).to eq "double"
|
|
148
|
-
expect(slice[10]).to eq 123.0
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it "should subset with [ by :all, column index and allowing for 'drop' parameter" do
|
|
152
|
-
expect(@mtcars[:all, 1]).to eq @mtcars[:all, 1, drop: true]
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
it "should subset with [ and column name" do
|
|
156
|
-
slice = @mtcars['drat']
|
|
157
|
-
expect(slice.typeof).to eq "list"
|
|
158
|
-
expect(slice.rclass).to eq "data.frame"
|
|
159
|
-
expect(slice.length).to eq 1
|
|
160
|
-
expect(slice[[1]][1]).to eq 3.90
|
|
161
|
-
expect(slice[[1, 1]]).to eq 3.90
|
|
162
|
-
# undefined columns selected (RError)
|
|
163
|
-
expect { slice['Mazda RX4'] }.to raise_error(RuntimeError)
|
|
164
|
-
expect(slice[['Mazda RX4']]).to eq nil
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
it "should subset with [ and row name" do
|
|
168
|
-
slice = @mtcars['Merc 450SE', :all]
|
|
169
|
-
expect(slice[[1]]).to eq 16.4
|
|
170
|
-
expect(slice[['hp']]).to eq 180.0
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
it "should subset with [ and row and column name" do
|
|
174
|
-
slice = @mtcars['Merc 450SL', 'drat']
|
|
175
|
-
expect(slice).to eq 3.07
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
#----------------------------------------------------------------------------------------
|
|
181
|
-
context "Subsetting with '[['" do
|
|
182
|
-
|
|
183
|
-
before(:each) do
|
|
184
|
-
@mtcars = ~:mtcars
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
it "should subset with [[ and a column index" do
|
|
188
|
-
slice = @mtcars[[1]]
|
|
189
|
-
expect(slice.typeof).to eq "double"
|
|
190
|
-
expect(slice.rclass).to eq "numeric"
|
|
191
|
-
expect(slice[1]).to eq 21.0
|
|
192
|
-
expect(slice[16]).to eq 10.4
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
it "should subset with [[ and a row index" do
|
|
196
|
-
slice = @mtcars
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
it "should subset with [[ and row and column indices" do
|
|
200
|
-
expect(@mtcars[[6, 1]]).to eq 18.1
|
|
201
|
-
expect(@mtcars[[6, 5]]).to eq 2.76
|
|
202
|
-
expect(@mtcars[[15, 1]]).to eq 10.4
|
|
203
|
-
expect(@mtcars[[15, 7]]).to eq 17.98
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
it "should subset with [[ and row and column names" do
|
|
207
|
-
expect(@mtcars[['Valiant', 'mpg']]).to eq 18.1
|
|
208
|
-
expect(@mtcars[['Valiant', 'drat']]).to eq 2.76
|
|
209
|
-
expect(@mtcars[['Cadillac Fleetwood', 'mpg']]).to eq 10.4
|
|
210
|
-
expect(@mtcars[['Cadillac Fleetwood', 'qsec']]).to eq 17.98
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
#----------------------------------------------------------------------------------------
|
|
216
|
-
context "Assigning with '[<-'" do
|
|
217
|
-
|
|
218
|
-
before(:each) do
|
|
219
|
-
@mtcars = ~:mtcars
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
it "should add a column to a dataframe indexing by column" do
|
|
223
|
-
@mtcars["New Column"] = R.c((1..32))
|
|
224
|
-
expect(@mtcars[[1, 12]]).to eq 1
|
|
225
|
-
expect(@mtcars[['Mazda RX4', 'New Column']]).to eq 1
|
|
226
|
-
end
|
|
227
|
-
|
|
228
|
-
it "should add a column to a dataframe indexing with :all in the row" do
|
|
229
|
-
@mtcars[:all, 'New Column'] = R.c((1..32))
|
|
230
|
-
expect(@mtcars[[1, 12]]).to eq 1
|
|
231
|
-
expect(@mtcars[['Mazda RX4', 'New Column']]).to eq 1
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
it "should assign to an element of a dataframe indexing with row and column by number" do
|
|
235
|
-
@mtcars[17, 6] = 1000
|
|
236
|
-
expect(@mtcars[[17, 6]]).to eq 1000.0
|
|
237
|
-
expect(@mtcars[['Chrysler Imperial', 'wt']]).to eq 1000.0
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
it "should assign to a range" do
|
|
241
|
-
@mtcars[(10..12)] = R.list((1..32), nil, "New Col": R.c(32..1))
|
|
242
|
-
expect(@mtcars[['Fiat 128', 'gear']]).to eq 18
|
|
243
|
-
expect(@mtcars[['Chrysler Imperial', 'New Col']]).to eq 16
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
#----------------------------------------------------------------------------------------
|
|
249
|
-
context "Ruby 'each'" do
|
|
250
|
-
|
|
251
|
-
it "should do 'each_column'" do
|
|
252
|
-
|
|
253
|
-
mtcars = ~:mtcars
|
|
254
|
-
|
|
255
|
-
mtcars.each_column do |col, col_name|
|
|
256
|
-
# col_name a Ruby string with the column name
|
|
257
|
-
case col_name
|
|
258
|
-
when "mpg"
|
|
259
|
-
expect(col[1]).to eq 21.0
|
|
260
|
-
expect(col[9]).to eq 22.8
|
|
261
|
-
expect(col[32]).to eq 21.4
|
|
262
|
-
expect(col[1] == 21.0).to eq true
|
|
263
|
-
expect(col[9] == 22.8).to eq true
|
|
264
|
-
expect(col[9] == 30).to eq false
|
|
265
|
-
expect(col[32] == 21.4).to eq true
|
|
266
|
-
when "cyl"
|
|
267
|
-
expect(col[1] == 6.0).to eq true
|
|
268
|
-
expect(col[10] == 6.0).to eq true
|
|
269
|
-
expect(col[32] == 4.0).to eq true
|
|
270
|
-
expect(col[1]).to eq 6.0
|
|
271
|
-
expect(col[10]).to eq 6.0
|
|
272
|
-
expect(col[32]).to eq 4.0
|
|
273
|
-
when "disp"
|
|
274
|
-
expect(col[1]).to eq 160.0
|
|
275
|
-
expect(col[32]).to eq 121.0
|
|
276
|
-
expect(col[1] == 160.0).to eq true
|
|
277
|
-
expect(col[1] == 200.0).to eq false
|
|
278
|
-
expect(col[32] == 121.0).to eq true
|
|
279
|
-
end
|
|
280
|
-
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
end
|
|
284
|
-
|
|
285
|
-
it "should do 'each_row'" do
|
|
286
|
-
|
|
287
|
-
mtcars = ~:mtcars
|
|
288
|
-
|
|
289
|
-
mtcars.each_row do |row, row_name|
|
|
290
|
-
# row_name a Ruby string with the column name
|
|
291
|
-
case row_name
|
|
292
|
-
when "Mazda RX4"
|
|
293
|
-
expect(row[['mpg']]).to eq 21.0
|
|
294
|
-
# indexig with only '[ returns a data.frame which is not
|
|
295
|
-
# equal to 21.0
|
|
296
|
-
expect(row['mpg']).not_to eq 21.0
|
|
297
|
-
expect(row.mpg).to eq 21.0
|
|
298
|
-
expect(row.qsec).to eq 16.46
|
|
299
|
-
expect(row[['mpg']] == 21.0).to eq true
|
|
300
|
-
expect(row.qsec == 16.46).to eq true
|
|
301
|
-
when "Hornet Sportabout"
|
|
302
|
-
expect(row[['cyl']]).to eq 8.0
|
|
303
|
-
expect(row.cyl).to eq 8.0
|
|
304
|
-
expect(row[['wt']]).to eq 3.44
|
|
305
|
-
when "Merc 240D"
|
|
306
|
-
expect(row[['hp']]).to eq 62.0
|
|
307
|
-
expect(row[['hp']] == 62.0).to eq true
|
|
308
|
-
expect(row[['cyl']] == 4.0).to eq true
|
|
309
|
-
expect(row[['wt']] == 3.19).to eq true
|
|
310
|
-
expect(row.drat).to eq 3.69
|
|
311
|
-
when "Volvo 142E"
|
|
312
|
-
expect(row.hp).to eq 109.0
|
|
313
|
-
expect(row.am).to eq 1.0
|
|
314
|
-
expect(row.carb).to eq 2.0
|
|
315
|
-
end
|
|
316
|
-
|
|
317
|
-
end
|
|
318
|
-
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
end
|
|
322
|
-
|
|
323
|
-
#----------------------------------------------------------------------------------------
|
|
324
|
-
context "Bootsraping" do
|
|
325
|
-
|
|
326
|
-
before(:each) do
|
|
327
|
-
@df = R.data__frame(x: R.rep((1..3), each: 2), y: (6..1), z: (~:letters)[(1..6)])
|
|
328
|
-
R.set__seed(10)
|
|
329
|
-
end
|
|
330
|
-
|
|
331
|
-
it "should do reordering with integer subsetting" do
|
|
332
|
-
|
|
333
|
-
table = @df[R.sample(@df.nrow), :all]
|
|
334
|
-
expect(table.x[3]).to eq 1
|
|
335
|
-
expect(table.y[2]).to eq 6
|
|
336
|
-
expect(table.z.levels[6]).to eq "f"
|
|
337
|
-
|
|
338
|
-
end
|
|
339
|
-
|
|
340
|
-
it "should select random rows with integer subsetting" do
|
|
341
|
-
table = @df[R.sample(@df.nrow, 3), :all]
|
|
342
|
-
|
|
343
|
-
expect(table.x[3]).to eq 1
|
|
344
|
-
expect(table.y[1]).to eq 4
|
|
345
|
-
expect(table.z.levels[table.z[2]]).to eq "a"
|
|
346
|
-
end
|
|
347
|
-
|
|
348
|
-
it "should randomly reorder a dataframe" do
|
|
349
|
-
df2 = @df[R.sample(@df.nrow), (3..1)]
|
|
350
|
-
|
|
351
|
-
expect(df2.z.levels[df2.z[4]]).to eq "f"
|
|
352
|
-
expect(df2.y[2]).to eq 6
|
|
353
|
-
expect(df2.x[5]).to eq 2
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
it "should reorder by a given variable" do
|
|
357
|
-
df2 = @df[R.sample(@df.nrow), (3..1)]
|
|
358
|
-
df2 = df2[df2.x.order, :all]
|
|
359
|
-
|
|
360
|
-
expect(df2.x[1]).to eq 1
|
|
361
|
-
expect(df2.y[1]).to eq 6
|
|
362
|
-
expect(df2.z.levels[df2.z[1]]).to eq "a"
|
|
363
|
-
end
|
|
364
|
-
|
|
365
|
-
it "should reorder variables" do
|
|
366
|
-
df2 = @df[R.sample(@df.nrow), (3..1)]
|
|
367
|
-
df2 = df2[df2.x.order, :all]
|
|
368
|
-
|
|
369
|
-
df2 = df2[:all, df2.names.order]
|
|
370
|
-
|
|
371
|
-
expect(df2.names.all__equal R.c("x", "y", "z")).to eq true
|
|
372
|
-
end
|
|
373
|
-
|
|
374
|
-
end
|
|
375
|
-
|
|
376
|
-
# df = R.tibble::tibble(x = 1:3, y = 3:1, z = letters[1:3])
|
|
377
|
-
|
|
378
|
-
end
|
|
379
|
-
|
data/specs/r_environment.spec.rb
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
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
|
-
|
|
24
|
-
require 'galaaz'
|
|
25
|
-
|
|
26
|
-
describe R::Environment do
|
|
27
|
-
|
|
28
|
-
#----------------------------------------------------------------------------------------
|
|
29
|
-
context "Using environment" do
|
|
30
|
-
|
|
31
|
-
before(:each) do
|
|
32
|
-
# create two environments
|
|
33
|
-
@a_env = R.env
|
|
34
|
-
@b_env = R.env
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "should allow the creation of new environments" do
|
|
38
|
-
expect(@a_env.typeof).to eq R.c("environment")
|
|
39
|
-
expect(@a_env.rclass).to eq R.c("environment")
|
|
40
|
-
expect(@a_env.env_names.length).to eq 0
|
|
41
|
-
expect(@b_env.env_names.length).to eq 0
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "should allow accessing key, value pairs to environments, with 'set' and 'get'" do
|
|
45
|
-
@a_env.set(:a, 25)
|
|
46
|
-
expect(@a_env.env_names.length).to eq 1
|
|
47
|
-
expect(@a_env.env_names).to eq R.c("a")
|
|
48
|
-
|
|
49
|
-
expect(@b_env.env_names.length).to eq 0
|
|
50
|
-
expect(@a_env.get(:a)).to eq 25
|
|
51
|
-
@a_env.set(:b, 33)
|
|
52
|
-
expect(@a_env.env_names.length).to eq 2
|
|
53
|
-
expect(@a_env.env_names).to eq R.c("a", "b")
|
|
54
|
-
|
|
55
|
-
expect(@a_env.get(:b)).to eq 33
|
|
56
|
-
expect(@a_env.get(:b)).not_to eq 25
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "should allow accessing key, value pairs to environments, with '.x' and 'x ='" do
|
|
60
|
-
expect(@a_env.env_names.length).to eq 0
|
|
61
|
-
@a_env.a = 30
|
|
62
|
-
expect(@a_env.env_names.length).to eq 1
|
|
63
|
-
expect(@a_env.a).to eq 30
|
|
64
|
-
|
|
65
|
-
@b_env.vec = R.c(1, 2, 3, 4)
|
|
66
|
-
expect(@b_env.env_names).to eq "vec"
|
|
67
|
-
expect(@b_env.env_names.length).to eq 1
|
|
68
|
-
expect(@b_env.vec).to eq R.c(1, 2, 3, 4)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "should allow accessing key, value pairs to environments, with '[[" do
|
|
72
|
-
expect(@a_env.env_names.length).to eq 0
|
|
73
|
-
@a_env.a = "This is a string"
|
|
74
|
-
expect(@a_env[["a"]]).to eq R.c("This is a string")
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "should call methods on the environment as every other R::Object" do
|
|
78
|
-
# we have already seen that we can apply 'ls' to an environment
|
|
79
|
-
expect(@a_env.env_names.length).to eq 0
|
|
80
|
-
expect(R.env_names(@a_env).length).to eq 0
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "allows multiple names to point to the same object" do
|
|
84
|
-
@a_env.a = false
|
|
85
|
-
@a_env.b = "a"
|
|
86
|
-
@a_env.c = (2..3)
|
|
87
|
-
@a_env.d = (1..3)
|
|
88
|
-
|
|
89
|
-
expect(@a_env.b).to eq "a"
|
|
90
|
-
expect(@a_env.d).to eq R.c(1, 2, 3)
|
|
91
|
-
|
|
92
|
-
@a_env.a = @a_env.d
|
|
93
|
-
expect(@a_env.a).to eq R.c(1, 2, 3)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "should allow removing elements from an environment" do
|
|
97
|
-
@a_env.a = false
|
|
98
|
-
@a_env.b = "a"
|
|
99
|
-
@a_env.c = (2..3)
|
|
100
|
-
@a_env.d = (1..3)
|
|
101
|
-
|
|
102
|
-
expect(@a_env.a).to eq false
|
|
103
|
-
expect(@a_env.b).to eq "a"
|
|
104
|
-
R.rm("a", envir: @a_env)
|
|
105
|
-
expect { @a_env.a }.to raise_error(NoMethodError)
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
it "should not be able to subset the environment with '['" do
|
|
109
|
-
@a_env.a = false
|
|
110
|
-
expect { @a_env['a'] }.to raise_error(RuntimeError)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
#----------------------------------------------------------------------------------------
|
|
116
|
-
context "Evaluating expressions" do
|
|
117
|
-
|
|
118
|
-
before(:each) do
|
|
119
|
-
R.len = 10
|
|
120
|
-
R.sd = 20
|
|
121
|
-
vec = R.c(1, 2, 3, 4)
|
|
122
|
-
R.x = R.c(1, 2, 3, 4)
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it "should evaluate an expression in the context of a data maks" do
|
|
126
|
-
myenv = R.env
|
|
127
|
-
myenv.e1 = R.expr(:len)
|
|
128
|
-
myenv.e2 = R.expr(:sd)
|
|
129
|
-
myenv.e3 = R.expr(R.c(1, 2, 3, 4))
|
|
130
|
-
|
|
131
|
-
e4 = R.expr(:e1 + :e2 + :e3)
|
|
132
|
-
expect(e4.to_s).to eq "e1 + e2 + e3"
|
|
133
|
-
expect(e4.eval(myenv.new_data_mask)).to eq R.c(31, 32, 33, 34)
|
|
134
|
-
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
end
|
|
140
|
-
|