galaaz 2.1.7 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +63 -58
- data/blogs/galaaz_ggplot/galaaz_ggplot.log +59 -68
- data/blogs/galaaz_ggplot/galaaz_ggplot.md +91 -84
- data/blogs/galaaz_ggplot/galaaz_ggplot.tex +125 -94
- 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/gknit/gknit.Rmd +33 -28
- data/blogs/gknit/gknit.md +47 -42
- data/blogs/gknit/gknit.tex +1368 -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/gknit_files/figure-latex/bubble-1.png +0 -0
- data/blogs/gknit/gknit_files/gknit_files/figure-latex/bubble-1.png +0 -0
- data/blogs/manual/manual.Rmd +129 -60
- data/blogs/manual/manual.log +289 -545
- data/blogs/manual/manual.md +551 -467
- data/blogs/manual/manual.tex +1059 -485
- data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
- data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
- data/blogs/manual/manual_files/figure-markdown_github/bubble-1.png +0 -0
- data/blogs/manual/manual_files/figure-markdown_github/diverging_bar.png +0 -0
- data/blogs/manual/manual_files/manual_files/figure-latex/bubble-1.png +0 -0
- data/blogs/nse_dplyr/nse_dplyr.Rmd +28 -7
- data/blogs/nse_dplyr/nse_dplyr.log +49 -153
- data/blogs/nse_dplyr/nse_dplyr.md +676 -705
- data/blogs/nse_dplyr/nse_dplyr.tex +1589 -0
- data/blogs/oh_my/oh_my.Rmd +193 -55
- data/blogs/oh_my/oh_my.log +265 -95
- data/blogs/oh_my/oh_my.md +236 -95
- data/blogs/oh_my/oh_my.tex +1976 -68
- data/blogs/ruby_plot/ruby_plot.Rmd +42 -34
- data/blogs/ruby_plot/ruby_plot.log +101 -99
- data/blogs/ruby_plot/ruby_plot.md +52 -46
- data/blogs/ruby_plot/ruby_plot.tex +134 -102
- 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/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/dose_len.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
- data/lib/galaaz/cli.rb +51 -10
- data/script/omarchy/README.md +1 -1
- data/script/omarchy/galaaz-guide.sh +1 -1
- data/sty/galaaz.sty +22 -0
- data/version.rb +1 -1
- metadata +19 -1
|
@@ -26,16 +26,15 @@ general-purpose programming language. It was designed and developed in the mid-1
|
|
|
26
26
|
"Matz" Matsumoto in Japan." It reached high popularity with the development of Ruby on Rails
|
|
27
27
|
(RoR) by David Heinemeier Hansson. RoR is a web application framework first released
|
|
28
28
|
around 2005. It makes extensive use of Ruby's metaprogramming features. With RoR,
|
|
29
|
-
Ruby became very popular. According to [Ruby
|
|
30
|
-
it
|
|
31
|
-
|
|
32
|
-
most popular language.
|
|
29
|
+
Ruby became very popular. According to [Ruby’s ranking in the TIOBE index](https://www.tiobe.com/tiobe-index/ruby/)
|
|
30
|
+
it **peaked** in popularity around 2008, then declined until 2015 when it started picking up again.
|
|
31
|
+
As of the original publication date (November 2018), TIOBE placed Ruby around 16th among languages.
|
|
33
32
|
|
|
34
|
-
Python,
|
|
35
|
-
|
|
33
|
+
Python, often grouped with Ruby as a high-level scripting language, ranked higher in that same snapshot.
|
|
34
|
+
Ruby is often criticized for its focus on web applications.
|
|
36
35
|
But Ruby can do [much more](https://github.com/markets/awesome-ruby) than just web applications.
|
|
37
|
-
Yet, for scientific computing, Ruby lags
|
|
38
|
-
Django
|
|
36
|
+
Yet, for scientific computing, Ruby lags behind Python and R. Python combines web frameworks such as
|
|
37
|
+
Django with NumPy, pandas, SciPy, and **a very large ecosystem** of domain-specific packages.
|
|
39
38
|
R is a free software environment for statistical computing and graphics with thousands
|
|
40
39
|
of libraries for data analysis.
|
|
41
40
|
|
|
@@ -53,7 +52,7 @@ Ruby and R could share one JVM runtime. That stack is **no longer** what Galaaz
|
|
|
53
52
|
today’s Galaaz is developed and tested with **JRuby or CRuby + GNU R** (see the project manual for
|
|
54
53
|
setup and command-line tools).
|
|
55
54
|
|
|
56
|
-
Library wrapping is a
|
|
55
|
+
Library wrapping is a common way to bring features from one language into another.
|
|
57
56
|
To improve performance, Python often wraps more efficient C libraries. For the
|
|
58
57
|
Python developer, the existence of such C libraries is hidden. The problem with
|
|
59
58
|
library wrapping is that for any new library, there is the need to handcraft a new
|
|
@@ -64,7 +63,7 @@ in Ruby. Doing so, all thousands of R libraries are available immediately
|
|
|
64
63
|
to Ruby developers without any new wrapping effort.
|
|
65
64
|
|
|
66
65
|
To show the power of Galaaz, we show in this article how Ruby can use R's ggplot2
|
|
67
|
-
library
|
|
66
|
+
library **transparently**, bringing to Ruby the power of high-quality scientific plotting.
|
|
68
67
|
We also show that migrating from R to Ruby with Galaaz is a matter of small
|
|
69
68
|
syntactic changes. By using Ruby, the R developer can use all of Ruby's powerful
|
|
70
69
|
object-oriented features. Also, with Ruby, it becomes much easier to move code
|
|
@@ -86,8 +85,8 @@ language and don't need special knowledge.
|
|
|
86
85
|
|
|
87
86
|
_Knitr_ is an application that converts text written in rmarkdown to many
|
|
88
87
|
different output formats. For instance, a writer can convert an rmarkdown document
|
|
89
|
-
to HTML,
|
|
90
|
-
text and _code chunks_.
|
|
88
|
+
to HTML, LaTeX, Word, and many other formats. R Markdown documents can contain
|
|
89
|
+
text and _code chunks_. knitr formats code chunks in a shaded box in the output document.
|
|
91
90
|
It also executes the code chunks and formats the output in a white box. Every line of
|
|
92
91
|
output from the execution code is preceded by '##'.
|
|
93
92
|
|
|
@@ -101,7 +100,7 @@ With _gKnit_ Ruby code chunks can share data.
|
|
|
101
100
|
# Exploring the Dataset
|
|
102
101
|
|
|
103
102
|
Let's start by exploring our selected dataset. ToothGrowth is an R dataset. A dataset
|
|
104
|
-
is like a simple
|
|
103
|
+
is like a simple Excel spreadsheet, in which each column has only one type of data.
|
|
105
104
|
For instance one column can have float, the other integer, and a third strings.
|
|
106
105
|
This dataset analyzes the length of odontoblasts (cells responsible for tooth growth)
|
|
107
106
|
in 60 guinea pigs, where each animal received one of three dose levels of Vitamin C
|
|
@@ -110,7 +109,7 @@ in 60 guinea pigs, where each animal received one of three dose levels of Vitami
|
|
|
110
109
|
|
|
111
110
|
The ToothGrowth dataset contains three columns: 'len', 'supp' and 'dose'. Let's
|
|
112
111
|
take a look at a few rows of this dataset. In Galaaz, R variables are accessed
|
|
113
|
-
by using the corresponding Ruby symbol
|
|
112
|
+
by using the corresponding Ruby symbol with the tilde (`~`) operator. Note in the
|
|
114
113
|
following chunk that 'ToothGrowth' is the R variable and Ruby's 'tooth_growth' is
|
|
115
114
|
assigned the value of '~R[:ToothGrowth]'.
|
|
116
115
|
|
|
@@ -152,7 +151,7 @@ puts tooth_growth.len.head
|
|
|
152
151
|
|
|
153
152
|
The 'dose' column contains a numeric value with either, 0.5, 1 or 2, although the
|
|
154
153
|
first 6 rows as seen above only contain the 0.5 values. Even though those are
|
|
155
|
-
number, they are better interpreted as a [factor or
|
|
154
|
+
number, they are better interpreted as a [factor or category](https://swcarpentry.github.io/r-novice-inflammation/12-supp-factors/). So, let's convert our 'dose' column from numeric to 'factor'.
|
|
156
155
|
In R, the function 'as.factor' is used to convert data in a vector to factors. To use this
|
|
157
156
|
function from Galaaz the dot ('.') in the function name is substituted by '__' (double underline).
|
|
158
157
|
The function 'as.factor' becomes 'R.as__factor' or just 'as__factor' when chaining.
|
|
@@ -225,7 +224,7 @@ to form the final graphics.
|
|
|
225
224
|
In order to make a plot, we use the 'ggplot' function to the dataset. In R, this would be
|
|
226
225
|
written as ```ggplot(<dataset>, ...)```. Galaaz gives you the flexibility to use
|
|
227
226
|
either ```R.ggplot(<dataset>, ...)``` or ```<dataset>.ggplot(...)```. In the graph
|
|
228
|
-
specification
|
|
227
|
+
specification below, we use the second notation that looks more like Ruby.
|
|
229
228
|
ggplot uses the ‘aes’ method to specify
|
|
230
229
|
x and y axes; in this case, the 'dose' on the $x$ axis and the 'length' on
|
|
231
230
|
the $y$ axis: 'E.aes(x: :dose, y: :len)'. To specify the type of plot add a geom to
|
|
@@ -405,8 +404,9 @@ matches with the actual order of the colors in the plot.
|
|
|
405
404
|
|
|
406
405
|
``` ruby
|
|
407
406
|
bp = bp +
|
|
408
|
-
R.scale_fill_manual(
|
|
409
|
-
|
|
407
|
+
R.scale_fill_manual(
|
|
408
|
+
values: R.c("cyan", "deepskyblue", "deepskyblue4"),
|
|
409
|
+
breaks: R.c("2", "1", "0.5"))
|
|
410
410
|
|
|
411
411
|
puts bp
|
|
412
412
|
```
|
|
@@ -433,11 +433,13 @@ a boxplot known as a _violin plot_ with jittered data.
|
|
|
433
433
|
|
|
434
434
|
|
|
435
435
|
``` ruby
|
|
436
|
-
violin = base_tooth +
|
|
436
|
+
violin = base_tooth +
|
|
437
|
+
R.geom_violin(E.aes(fill: :dose)) +
|
|
437
438
|
R.facet_grid(R[:all].til :supp) +
|
|
438
439
|
R.geom_jitter(shape: 23, color: "cyan3", size: 1) +
|
|
439
|
-
R.scale_fill_manual(
|
|
440
|
-
|
|
440
|
+
R.scale_fill_manual(
|
|
441
|
+
values: R.c("cyan", "deepskyblue", "deepskyblue4"),
|
|
442
|
+
breaks: R.c("2", "1", "0.5"))
|
|
441
443
|
|
|
442
444
|
puts violin
|
|
443
445
|
```
|
|
@@ -502,42 +504,43 @@ written in 'bold'.
|
|
|
502
504
|
module CorpTheme
|
|
503
505
|
|
|
504
506
|
R.install_and_loads 'RColorBrewer'
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
# face
|
|
508
|
-
|
|
509
|
-
|
|
507
|
+
|
|
508
|
+
# ---------------------------------------------------------------
|
|
509
|
+
# face: 1=plain, 2=bold, 3=italic, 4=bold-italic
|
|
510
|
+
# ---------------------------------------------------------------
|
|
511
|
+
|
|
510
512
|
def self.text_element(size, face: "plain", hjust: nil)
|
|
511
|
-
E.element_text(color: "#000080",
|
|
513
|
+
E.element_text(color: "#000080",
|
|
512
514
|
face: face,
|
|
513
515
|
size: size,
|
|
514
|
-
|
|
516
|
+
hjust: hjust)
|
|
515
517
|
end
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
#
|
|
519
|
-
#
|
|
520
|
-
|
|
521
|
-
|
|
518
|
+
|
|
519
|
+
# ---------------------------------------------------------------
|
|
520
|
+
# Plot theme: no major/minor grids or borders; optional
|
|
521
|
+
# background for facets; turn off scientific notation.
|
|
522
|
+
# ---------------------------------------------------------------
|
|
523
|
+
|
|
522
524
|
def self.global_theme(faceted = false)
|
|
523
|
-
|
|
525
|
+
|
|
524
526
|
R.options(scipen: 999) # turn-off scientific notation like 1e+48
|
|
525
|
-
#
|
|
526
|
-
|
|
527
|
+
# R.theme_set(R.theme_bw)
|
|
528
|
+
|
|
527
529
|
# remove major grids
|
|
528
530
|
gb = R.theme(panel__grid__major: E.element_blank())
|
|
529
531
|
# remove minor grids
|
|
530
532
|
gb = gb + R.theme(panel__grid__minor: E.element_blank)
|
|
531
|
-
# gb = R.theme(panel__grid__minor: E.element_blank)
|
|
532
533
|
# remove border
|
|
533
534
|
gb = gb + R.theme(panel__border: E.element_blank)
|
|
534
|
-
#
|
|
535
|
-
|
|
536
|
-
|
|
535
|
+
# Keep background on faceted plots (helps separate facets)
|
|
536
|
+
if !faceted
|
|
537
|
+
gb = gb + R.theme(panel__background: E.element_blank)
|
|
538
|
+
end
|
|
537
539
|
# Change axis font
|
|
538
540
|
gb = gb + R.theme(axis__text: text_element(8))
|
|
539
541
|
# change axis title font
|
|
540
|
-
gb = gb + R.theme(
|
|
542
|
+
gb = gb + R.theme(
|
|
543
|
+
axis__title: text_element(10, face: "bold", hjust: 1))
|
|
541
544
|
# change font of title
|
|
542
545
|
gb = gb + R.theme(title: text_element(12, face: "bold"))
|
|
543
546
|
# change font of subtitle
|
|
@@ -546,7 +549,7 @@ module CorpTheme
|
|
|
546
549
|
gb = gb + R.theme(plot__caption: text_element(8))
|
|
547
550
|
|
|
548
551
|
end
|
|
549
|
-
|
|
552
|
+
|
|
550
553
|
end
|
|
551
554
|
```
|
|
552
555
|
|
|
@@ -593,9 +596,12 @@ Length of odontoblasts in 60 guinea pigs.
|
|
|
593
596
|
Each animal received one of three dose levels of vitamin C.
|
|
594
597
|
EOT
|
|
595
598
|
|
|
596
|
-
bp = tooth_growth.ggplot(
|
|
597
|
-
|
|
598
|
-
R.
|
|
599
|
+
bp = tooth_growth.ggplot(
|
|
600
|
+
E.aes(x: :supp, y: :len, group: :supp)) +
|
|
601
|
+
R.geom_boxplot(E.aes(fill: :supp)) +
|
|
602
|
+
R.facet_grid(R[:all].til :dose) +
|
|
603
|
+
R.scale_fill_manual(
|
|
604
|
+
values: R.c("cyan", "deepskyblue4")) +
|
|
599
605
|
R.labs(title: "Tooth Growth: Length by Dose",
|
|
600
606
|
subtitle: "Faceted by dose",
|
|
601
607
|
x: "Delivery method", y: "Teeth length",
|