galaaz 2.1.6 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +63 -58
  4. data/blogs/galaaz_ggplot/galaaz_ggplot.log +59 -68
  5. data/blogs/galaaz_ggplot/galaaz_ggplot.md +91 -84
  6. data/blogs/galaaz_ggplot/galaaz_ggplot.tex +125 -94
  7. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/midwest_rb.png +0 -0
  8. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/scatter_plot_rb.png +0 -0
  9. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/midwest_rb.png +0 -0
  10. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/scatter_plot_rb.png +0 -0
  11. data/blogs/gknit/gknit.Rmd +33 -28
  12. data/blogs/gknit/gknit.md +47 -42
  13. data/blogs/gknit/gknit.tex +1368 -0
  14. data/blogs/gknit/gknit_files/figure-html/bubble-1.png +0 -0
  15. data/blogs/gknit/gknit_files/figure-html/diverging_bar.png +0 -0
  16. data/blogs/gknit/gknit_files/figure-latex/bubble-1.png +0 -0
  17. data/blogs/gknit/gknit_files/gknit_files/figure-latex/bubble-1.png +0 -0
  18. data/blogs/manual/manual.Rmd +129 -60
  19. data/blogs/manual/manual.log +289 -545
  20. data/blogs/manual/manual.md +551 -467
  21. data/blogs/manual/manual.tex +1059 -485
  22. data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
  23. data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
  24. data/blogs/manual/manual_files/figure-markdown_github/bubble-1.png +0 -0
  25. data/blogs/manual/manual_files/figure-markdown_github/diverging_bar.png +0 -0
  26. data/blogs/manual/manual_files/manual_files/figure-latex/bubble-1.png +0 -0
  27. data/blogs/nse_dplyr/nse_dplyr.Rmd +28 -7
  28. data/blogs/nse_dplyr/nse_dplyr.log +49 -153
  29. data/blogs/nse_dplyr/nse_dplyr.md +676 -705
  30. data/blogs/nse_dplyr/nse_dplyr.tex +1589 -0
  31. data/blogs/oh_my/oh_my.Rmd +193 -55
  32. data/blogs/oh_my/oh_my.log +265 -95
  33. data/blogs/oh_my/oh_my.md +236 -95
  34. data/blogs/oh_my/oh_my.tex +1976 -68
  35. data/blogs/ruby_plot/ruby_plot.Rmd +42 -34
  36. data/blogs/ruby_plot/ruby_plot.log +101 -99
  37. data/blogs/ruby_plot/ruby_plot.md +52 -46
  38. data/blogs/ruby_plot/ruby_plot.tex +134 -102
  39. data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png +0 -0
  40. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png +0 -0
  41. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png +0 -0
  42. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png +0 -0
  43. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png +0 -0
  44. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png +0 -0
  45. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png +0 -0
  46. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png +0 -0
  47. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png +0 -0
  48. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png +0 -0
  49. data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png +0 -0
  50. data/blogs/ruby_plot/ruby_plot_files/figure-latex/dose_len.png +0 -0
  51. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
  52. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
  53. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
  54. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
  55. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
  56. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
  57. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
  58. data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
  59. data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
  60. data/blogs/ruby_plot/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
  61. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/dose_len.png +0 -0
  62. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
  63. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
  64. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
  65. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
  66. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
  67. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
  68. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
  69. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
  70. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
  71. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
  72. data/lib/galaaz/cli.rb +206 -11
  73. data/script/omarchy/README.md +94 -0
  74. data/script/omarchy/debug-galaaz.sh +91 -0
  75. data/script/omarchy/galaaz-add.sh +176 -0
  76. data/script/omarchy/galaaz-gknit.sh +73 -0
  77. data/script/omarchy/galaaz-guide.sh +123 -0
  78. data/script/omarchy/install-galaaz.sh +308 -0
  79. data/script/omarchy/omarchy-menu.jsonc +92 -0
  80. data/script/omarchy/remove-galaaz.sh +34 -0
  81. data/sty/galaaz.sty +22 -0
  82. data/version.rb +1 -1
  83. metadata +27 -1
@@ -5,15 +5,16 @@ language, with a large community, a very large set of libraries and
5
5
  great for web development. However, it lacks libraries for data science,
6
6
  statistics, scientific plotting and machine learning. On the other hand,
7
7
  R is considered one of the most powerful languages for solving all of
8
- the above problems. Maybe the strongest competitor to R is Python with
9
- libraries such as NumPy, Panda, SciPy, SciKit-Learn and a couple more.
8
+ the above problems. **Python** is a strong competitor: NumPy, pandas,
9
+ SciPy, and scikit-learn are widely used examples among **many
10
+ thousands** of packages on PyPI for numerical and ML work.
10
11
 
11
12
  With Galaaz we do not intend to re-implement any of the scientific
12
13
  libraries in R; we allow for very tight coupling between the two
13
14
  languages to the point that the Ruby developer does not need to think
14
15
  about R syntax for every call. **Galaaz 2.0** does this with
15
- **[JRuby](https://www.jruby.org/)** or **CRuby** and **GNU R**: a **bridge**
16
- evaluates R from Ruby and exchanges data between processes.
16
+ **[JRuby](https://www.jruby.org/)** or **CRuby** and **GNU R**: a
17
+ **bridge** evaluates R from Ruby and exchanges data between processes.
17
18
 
18
19
  An **earlier** Galaaz prototype used Oracle’s **GraalVM** with
19
20
  **TruffleRuby** and **FastR** in one JVM. That stack is **historical**;
@@ -56,9 +57,9 @@ but could be installed prior to the demo if desired:
56
57
  - ggplot2
57
58
  - gridExtra
58
59
 
59
- Installation of R packages requires a development environment. In Linux,
60
- the gnu compiler and tools should be enough. I am not sure what is
61
- needed on the Mac.
60
+ Installation of R packages requires a development environment. On Linux,
61
+ a typical build toolchain (GCC, headers) is usually enough. On macOS,
62
+ Apple’s **Xcode Command Line Tools** are commonly required.
62
63
 
63
64
  In order to run the ‘specs’ the following Ruby package is necessary:
64
65
 
@@ -70,33 +71,32 @@ In order to run the ‘specs’ the following Ruby package is necessary:
70
71
 
71
72
  ## Running the demo
72
73
 
73
- The ggplot for this demos was extracted from:
74
+ The ggplot examples for this demo were adapted from:
74
75
  <http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html>.
75
76
 
76
- On the console do
77
+ At the shell, from a suitable Galaaz environment:
77
78
 
78
- > galaaz master_list:scatter_plot
79
+ galaaz master_list:scatter_plot
79
80
 
80
81
  ## Running other demos
81
82
 
82
- Doing on the console
83
+ Running
83
84
 
84
- > galaaz -T
85
+ galaaz -T
85
86
 
86
- will show a list with all available demos. To run any of the demos in
87
- the list, substitute the call to ‘rake’ to ‘galaaz’. For instance, one
88
- of the examples in the list is ‘rake sthda:bar’. In order to run this
89
- example just do galaaz sthda:bar’. Doing ‘galaaz sthda:all’ will run
90
- all demos in the sthda cathegory. Some of the examples require ‘rspec
91
- do be available. To install ‘rspec’ just do ‘gem install rspec’.
87
+ lists available demo tasks. To run a demo, use **`galaaz`** where you
88
+ would otherwise invoke **`rake`**. For example, if the list shows
89
+ `rake sthda:bar`, run `galaaz sthda:bar`. To run every demo in the
90
+ **sthda** category, use `galaaz sthda:all`. Some examples require
91
+ **rspec**; install it with `gem install rspec`.
92
92
 
93
93
  # The demo code
94
94
 
95
95
  The following is the Ruby code and plot for the above example. There is
96
- a small difference between the code in the example and the code bellow.
97
- If the example is ran, the plot will appear on the screen, bellow, we
98
- generate an ‘svg’ image and then include it in this document. In order
99
- to generate and image, the R.svg device is used. To generate the plot on
96
+ a small difference between the code in the example and the code below.
97
+ If the example is **run**, the plot will appear on the screen; below, we
98
+ generate an SVG image and then include it in this document. In order to
99
+ generate and image, the R.svg device is used. To generate the plot on
100
100
  the screen, use the R.awt device, as commented on the code.
101
101
 
102
102
  ``` ruby
@@ -192,38 +192,43 @@ notation and the preferred color is blue.
192
192
  ``` ruby
193
193
  # corp_theme.rb
194
194
  # defines the corporate theme for all plots
195
-
195
+
196
196
  module CorpTheme
197
197
 
198
- #---------------------------------------------------------------------------------
199
- # Defines the plot theme (visualization). In this theme we remove major and minor
200
- # grids, borders and background. We also turn-off scientific notation.
201
- #---------------------------------------------------------------------------------
202
-
198
+ # ---------------------------------------------------------------
199
+ # Plot theme: no major/minor grids, borders, or background;
200
+ # turn off scientific notation.
201
+ # ---------------------------------------------------------------
202
+
203
203
  def self.global_theme
204
-
204
+
205
205
  R.options(scipen: 999) # turn-off scientific notation like 1e+48
206
-
206
+
207
207
  # remove major grids
208
- global_theme = R.theme(panel__grid__major: E.element_blank())
208
+ global_theme =
209
+ R.theme(panel__grid__major: E.element_blank())
209
210
  # remove minor grids
210
- global_theme = global_theme + R.theme(panel__grid__minor: E.element_blank)
211
+ global_theme = global_theme +
212
+ R.theme(panel__grid__minor: E.element_blank)
211
213
  # remove border
212
- global_theme = global_theme + R.theme(panel__border: E.element_blank)
214
+ global_theme = global_theme +
215
+ R.theme(panel__border: E.element_blank)
213
216
  # remove background
214
- global_theme = global_theme + R.theme(panel__background: E.element_blank)
217
+ global_theme = global_theme +
218
+ R.theme(panel__background: E.element_blank)
215
219
  # Change axis font
216
220
  global_theme = global_theme +
217
- R.theme(axis__text: E.element_text(size: 8, color: "#000080"))
221
+ R.theme(axis__text: E.element_text(
222
+ size: 8, color: "#000080"))
218
223
  # change color of axis titles
219
224
  global_theme = global_theme +
220
- R.theme(axis__title: E.element_text(
221
- color: "#000080",
222
- face: "bold",
223
- size: 8,
224
- hjust: 1))
225
+ R.theme(axis__title: E.element_text(
226
+ color: "#000080",
227
+ face: "bold",
228
+ size: 8,
229
+ hjust: 1))
225
230
  end
226
-
231
+
227
232
  end
228
233
  ```
229
234
 
@@ -232,7 +237,7 @@ We now define a ScatterPlot class:
232
237
  ``` ruby
233
238
  # ScatterPlot.rb
234
239
  # creates a scatter plot and allow some configuration
235
-
240
+
236
241
  class ScatterPlot
237
242
 
238
243
  attr_accessor :title
@@ -240,55 +245,55 @@ class ScatterPlot
240
245
  attr_accessor :caption
241
246
  attr_accessor :x_label
242
247
  attr_accessor :y_label
243
-
244
- #---------------------------------------------------------------------------------
248
+
249
+ # ---------------------------------------------------------------
245
250
  # Initialize the plot with the data and the x and y variables
246
- #---------------------------------------------------------------------------------
251
+ # ---------------------------------------------------------------
247
252
 
248
253
  def initialize(data, x:, y:)
249
254
  @data = data
250
255
  @x = x
251
256
  @y = y
252
257
  end
253
-
254
- #---------------------------------------------------------------------------------
258
+
259
+ # ---------------------------------------------------------------
255
260
  # Define groupings by color and size
256
- #---------------------------------------------------------------------------------
261
+ # ---------------------------------------------------------------
257
262
 
258
263
  def group_by(color:, size:)
259
264
  @color_by = color
260
265
  @size_by = size
261
266
  end
262
267
 
263
- #---------------------------------------------------------------------------------
264
- # Add a smoothing line, and if confidence is true the add a confidence interval, if
265
- # false does not add the confidence interval
266
- #---------------------------------------------------------------------------------
268
+ # ---------------------------------------------------------------
269
+ # Add a smoothing line; confidence: true draws a CI band.
270
+ # ---------------------------------------------------------------
267
271
 
268
272
  def add_smoothing_line(method:, confidence: true)
269
273
  @method = method
270
274
  @confidence = confidence
271
275
  end
272
-
273
- #---------------------------------------------------------------------------------
274
- # Creates the graph title, properly formated for this theme
275
- # @param title [String] The title to add to the graph
276
- # @return textGrob that can be included in a graph
277
- #---------------------------------------------------------------------------------
278
-
279
- def graph_params(title: "", subtitle: "", caption: "", x_label: "", y_label: "")
276
+
277
+ # ---------------------------------------------------------------
278
+ # Graph title / labels, formatted for this theme.
279
+ # @param title [String] title to add to the graph
280
+ # @return labs() result that can be included in a graph
281
+ # ---------------------------------------------------------------
282
+
283
+ def graph_params(title: "", subtitle: "", caption: "",
284
+ x_label: "", y_label: "")
280
285
  R.labs(
281
- title: title,
282
- subtitle: subtitle,
286
+ title: title,
287
+ subtitle: subtitle,
283
288
  caption: caption,
284
- y_label: y_label,
285
- x_label: x_label,
289
+ y_label: y_label,
290
+ x_label: x_label,
286
291
  )
287
292
  end
288
293
 
289
- #---------------------------------------------------------------------------------
294
+ # ---------------------------------------------------------------
290
295
  # Prepare the plot's points
291
- #---------------------------------------------------------------------------------
296
+ # ---------------------------------------------------------------
292
297
 
293
298
  def points
294
299
  params = {}
@@ -296,28 +301,27 @@ class ScatterPlot
296
301
  params[:size] = @size_by if @size_by
297
302
  R.geom_point(E.aes(params))
298
303
  end
299
-
300
- #---------------------------------------------------------------------------------
304
+
305
+ # ---------------------------------------------------------------
301
306
  # Plots the scatterplot
302
- #---------------------------------------------------------------------------------
307
+ # ---------------------------------------------------------------
303
308
 
304
309
  def plot
305
310
  gg = @data.ggplot(E.aes(x: @x, y: @y)) +
306
- points +
311
+ points +
307
312
  R.geom_smooth(method: @method, se: @confidence) +
308
313
  R.xlim(R.c(0, 0.1)) +
309
- R.ylim(R.c(0, 500000)) +
314
+ R.ylim(R.c(0, 500000)) +
310
315
  graph_params(title: @title,
311
- subtitle: @subtitle,
312
- y_label: @y_label,
313
- x_label: @x_label,
316
+ subtitle: @subtitle,
317
+ y_label: @y_label,
318
+ x_label: @x_label,
314
319
  caption: @caption) +
315
320
  CorpTheme.global_theme
316
321
 
317
322
  puts gg
318
-
319
323
  end
320
-
324
+
321
325
  end
322
326
  ```
323
327
 
@@ -334,9 +338,10 @@ sp.subtitle = "Area Vs Population"
334
338
  sp.caption = "Source: midwest"
335
339
  sp.x_label = "Area"
336
340
  sp.y_label = "Population"
337
- sp.group_by(color: :state, size: :popdensity) # try sp.group_by(color: :state)
341
+ # try: sp.group_by(color: :state)
342
+ sp.group_by(color: :state, size: :popdensity)
338
343
  # available methods: "lm", "glm", "loess", "gam"
339
- sp.add_smoothing_line(method: "glm")
344
+ sp.add_smoothing_line(method: "glm")
340
345
  sp.plot
341
346
  ```
342
347
 
@@ -347,9 +352,10 @@ sp.plot
347
352
  R is a very powerful language for statistical analysis, data analytics,
348
353
  machine learning, plotting and many other scientific applications with a
349
354
  very large package ecosystem. However R is often considered hard to
350
- learn and lacking modern computer languages constructs such as object
351
- oriented classes, modules, lambdas, etc. For this reason, many
352
- developers have started or switched from R to Python.
355
+ learn and lacking modern language features such as object-oriented
356
+ classes, modules, and first-class functions. For that reason, many teams
357
+ have standardized on Python (or stayed entirely inside R) rather than
358
+ mixing ecosystems.
353
359
 
354
360
  With Galaaz, R programmers can almost transparently migrate from R to
355
361
  Ruby, since syntax is almost identical and **GNU R** remains the engine
@@ -359,6 +365,7 @@ nicely complement R packages.
359
365
 
360
366
  For the Ruby developer, Galaaz allows the immediate use of R functions
361
367
  with minimal ceremony. As shown in the second example above, class
362
- `ScatterPlot` hides most R call details from the Ruby developer.
363
- Prefer **JRuby** when you want **real parallel threads** on the Ruby side and access
364
- to the JVM ecosystem; **CRuby** works equally for the Galaaz bridge itself.
368
+ `ScatterPlot` hides most R call details from the Ruby developer. Prefer
369
+ **JRuby** when you want **real parallel threads** on the Ruby side and
370
+ access to the JVM ecosystem; **CRuby** works equally for the Galaaz
371
+ bridge itself.