galaaz 2.1.7 → 2.1.9
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 +39 -0
- data/Rakefile +20 -2
- data/bin/check_gemfile_lock_version +46 -0
- data/bin/release_bump +26 -0
- data/blogs/README.md +4 -0
- data/blogs/galaaz_2_0/galaaz_2_0.Rmd +385 -0
- data/blogs/galaaz_2_0/galaaz_2_0.md +409 -0
- data/blogs/galaaz_2_0/galaaz_2_0.tex +756 -0
- data/blogs/galaaz_2_0/images/galaaz-header.png +0 -0
- data/blogs/galaaz_2_0/images/galaaz-lockup-stacked.png +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +76 -58
- data/blogs/galaaz_ggplot/galaaz_ggplot.md +188 -161
- data/blogs/galaaz_ggplot/galaaz_ggplot.tex +185 -117
- 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/images/galaaz-lockup-stacked.png +0 -0
- data/blogs/gknit/gknit.Rmd +48 -28
- data/blogs/gknit/gknit.md +60 -43
- data/blogs/gknit/gknit.tex +1409 -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/images/galaaz-lockup-stacked.png +0 -0
- data/blogs/manual/images/galaaz-lockup-stacked.png +0 -0
- data/blogs/manual/manual.Rmd +161 -71
- data/blogs/manual/manual.md +573 -482
- data/blogs/manual/manual.tex +1113 -517
- 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/nse_dplyr/images/galaaz-lockup-stacked.png +0 -0
- data/blogs/nse_dplyr/nse_dplyr.Rmd +42 -8
- data/blogs/nse_dplyr/nse_dplyr.md +69 -50
- data/blogs/nse_dplyr/nse_dplyr.tex +1626 -0
- data/blogs/oh_my/images/galaaz-lockup-stacked.png +0 -0
- data/blogs/oh_my/oh_my.Rmd +206 -55
- data/blogs/oh_my/oh_my.md +247 -96
- data/blogs/oh_my/oh_my.tex +2038 -93
- data/blogs/r_on_rails_ledger/images/00_portfolio_page.png +0 -0
- data/blogs/r_on_rails_ledger/images/01_results_panel.png +0 -0
- data/blogs/r_on_rails_ledger/images/02_density_tail_risk.png +0 -0
- data/blogs/r_on_rails_ledger/images/03_mc_cone.png +0 -0
- data/blogs/r_on_rails_ledger/images/04_rolling_var.png +0 -0
- data/blogs/r_on_rails_ledger/images/galaaz-lockup-stacked.png +0 -0
- data/blogs/r_on_rails_ledger/r_on_rails_ledger.Rmd +354 -0
- data/blogs/r_on_rails_ledger/r_on_rails_ledger.md +365 -0
- data/blogs/r_on_rails_ledger/r_on_rails_ledger.tex +670 -0
- data/blogs/ruby_plot/images/galaaz-lockup-stacked.png +0 -0
- data/blogs/ruby_plot/ruby_plot.Rmd +56 -35
- data/blogs/ruby_plot/ruby_plot.md +63 -47
- data/blogs/ruby_plot/ruby_plot.tex +194 -125
- 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 +98 -13
- data/logos/icon-font/README.md +27 -0
- data/logos/icon-font/build_font.py +130 -0
- data/logos/icon-font/galaaz-mark.svg +34 -0
- data/script/omarchy/README.md +9 -2
- data/script/omarchy/fonts/galaaz.ttf +0 -0
- data/script/omarchy/galaaz-guide.sh +1 -1
- data/script/omarchy/install-galaaz.sh +8 -1
- data/script/omarchy/omarchy-menu.jsonc +21 -9
- data/sty/galaaz-header.png +0 -0
- data/sty/galaaz-headers-from-p3.tex +4 -0
- data/sty/galaaz.sty +76 -23
- data/version.rb +1 -1
- metadata +46 -7
- data/blogs/galaaz_ggplot/galaaz_ggplot.log +0 -754
- data/blogs/manual/manual.log +0 -1786
- data/blogs/nse_dplyr/nse_dplyr.log +0 -928
- data/blogs/oh_my/oh_my.log +0 -804
- data/blogs/ruby_plot/ruby_plot.log +0 -885
|
@@ -9,9 +9,17 @@ output:
|
|
|
9
9
|
html_document:
|
|
10
10
|
self_contained: true
|
|
11
11
|
keep_md: true
|
|
12
|
+
toc: true
|
|
13
|
+
toc_float: true
|
|
14
|
+
toc_depth: 2
|
|
15
|
+
number_sections: true
|
|
16
|
+
includes:
|
|
17
|
+
before_body: _logo_before_body.html
|
|
12
18
|
pdf_document:
|
|
13
19
|
includes:
|
|
14
|
-
in_header:
|
|
20
|
+
in_header:
|
|
21
|
+
- "../../sty/galaaz.sty"
|
|
22
|
+
- "../../sty/galaaz-headers-from-p3.tex"
|
|
15
23
|
keep_tex: yes
|
|
16
24
|
number_sections: yes
|
|
17
25
|
toc: true
|
|
@@ -20,10 +28,16 @@ fontsize: 11pt
|
|
|
20
28
|
---
|
|
21
29
|
|
|
22
30
|
```{r setup, echo=FALSE}
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
#
|
|
26
|
-
# knitr::opts_chunk$set(
|
|
31
|
+
# Narrower console width so printed output fits PDF code boxes.
|
|
32
|
+
options(width = 70)
|
|
33
|
+
# Example (unused): force svg figures at half page width
|
|
34
|
+
# knitr::opts_chunk$set(
|
|
35
|
+
# fig.width = 1, fig.height = 7, dev = "svg", out.width = "50%")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```{r brand_logo, echo=FALSE, fig.align='center', out.width='45%', eval=knitr::is_latex_output()}
|
|
39
|
+
# PDF only — HTML uses _logo_before_body.html (above the TOC).
|
|
40
|
+
knitr::include_graphics("images/galaaz-lockup-stacked.png")
|
|
27
41
|
```
|
|
28
42
|
|
|
29
43
|
According to Wikipedia "Ruby is a dynamic, interpreted, reflective, object-oriented,
|
|
@@ -356,8 +370,9 @@ matches with the actual order of the colors in the plot.
|
|
|
356
370
|
|
|
357
371
|
```{ruby facets_by_delivery_color2, dev = "png", fig.width = 540, fig.height = 560, units = "px"}
|
|
358
372
|
bp = bp +
|
|
359
|
-
R.scale_fill_manual(
|
|
360
|
-
|
|
373
|
+
R.scale_fill_manual(
|
|
374
|
+
values: R.c("cyan", "deepskyblue", "deepskyblue4"),
|
|
375
|
+
breaks: R.c("2", "1", "0.5"))
|
|
361
376
|
|
|
362
377
|
puts bp
|
|
363
378
|
```
|
|
@@ -380,11 +395,13 @@ a boxplot known as a _violin plot_ with jittered data.
|
|
|
380
395
|
> The central dot represents the median average value.
|
|
381
396
|
|
|
382
397
|
```{ruby violin_with_jitter, dev = "png", fig.width = 540, fig.height = 560, units = "px"}
|
|
383
|
-
violin = base_tooth +
|
|
398
|
+
violin = base_tooth +
|
|
399
|
+
R.geom_violin(E.aes(fill: :dose)) +
|
|
384
400
|
R.facet_grid(R[:all].til :supp) +
|
|
385
401
|
R.geom_jitter(shape: 23, color: "cyan3", size: 1) +
|
|
386
|
-
R.scale_fill_manual(
|
|
387
|
-
|
|
402
|
+
R.scale_fill_manual(
|
|
403
|
+
values: R.c("cyan", "deepskyblue", "deepskyblue4"),
|
|
404
|
+
breaks: R.c("2", "1", "0.5"))
|
|
388
405
|
|
|
389
406
|
puts violin
|
|
390
407
|
```
|
|
@@ -441,42 +458,43 @@ written in 'bold'.
|
|
|
441
458
|
module CorpTheme
|
|
442
459
|
|
|
443
460
|
R.install_and_loads 'RColorBrewer'
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
# face
|
|
447
|
-
|
|
448
|
-
|
|
461
|
+
|
|
462
|
+
# ---------------------------------------------------------------
|
|
463
|
+
# face: 1=plain, 2=bold, 3=italic, 4=bold-italic
|
|
464
|
+
# ---------------------------------------------------------------
|
|
465
|
+
|
|
449
466
|
def self.text_element(size, face: "plain", hjust: nil)
|
|
450
|
-
E.element_text(color: "#000080",
|
|
467
|
+
E.element_text(color: "#000080",
|
|
451
468
|
face: face,
|
|
452
469
|
size: size,
|
|
453
|
-
|
|
470
|
+
hjust: hjust)
|
|
454
471
|
end
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
#
|
|
458
|
-
#
|
|
459
|
-
|
|
460
|
-
|
|
472
|
+
|
|
473
|
+
# ---------------------------------------------------------------
|
|
474
|
+
# Plot theme: no major/minor grids or borders; optional
|
|
475
|
+
# background for facets; turn off scientific notation.
|
|
476
|
+
# ---------------------------------------------------------------
|
|
477
|
+
|
|
461
478
|
def self.global_theme(faceted = false)
|
|
462
|
-
|
|
479
|
+
|
|
463
480
|
R.options(scipen: 999) # turn-off scientific notation like 1e+48
|
|
464
|
-
#
|
|
465
|
-
|
|
481
|
+
# R.theme_set(R.theme_bw)
|
|
482
|
+
|
|
466
483
|
# remove major grids
|
|
467
484
|
gb = R.theme(panel__grid__major: E.element_blank())
|
|
468
485
|
# remove minor grids
|
|
469
486
|
gb = gb + R.theme(panel__grid__minor: E.element_blank)
|
|
470
|
-
# gb = R.theme(panel__grid__minor: E.element_blank)
|
|
471
487
|
# remove border
|
|
472
488
|
gb = gb + R.theme(panel__border: E.element_blank)
|
|
473
|
-
#
|
|
474
|
-
|
|
475
|
-
|
|
489
|
+
# Keep background on faceted plots (helps separate facets)
|
|
490
|
+
if !faceted
|
|
491
|
+
gb = gb + R.theme(panel__background: E.element_blank)
|
|
492
|
+
end
|
|
476
493
|
# Change axis font
|
|
477
494
|
gb = gb + R.theme(axis__text: text_element(8))
|
|
478
495
|
# change axis title font
|
|
479
|
-
gb = gb + R.theme(
|
|
496
|
+
gb = gb + R.theme(
|
|
497
|
+
axis__title: text_element(10, face: "bold", hjust: 1))
|
|
480
498
|
# change font of title
|
|
481
499
|
gb = gb + R.theme(title: text_element(12, face: "bold"))
|
|
482
500
|
# change font of subtitle
|
|
@@ -485,7 +503,7 @@ module CorpTheme
|
|
|
485
503
|
gb = gb + R.theme(plot__caption: text_element(8))
|
|
486
504
|
|
|
487
505
|
end
|
|
488
|
-
|
|
506
|
+
|
|
489
507
|
end
|
|
490
508
|
```
|
|
491
509
|
|
|
@@ -523,9 +541,12 @@ Length of odontoblasts in 60 guinea pigs.
|
|
|
523
541
|
Each animal received one of three dose levels of vitamin C.
|
|
524
542
|
EOT
|
|
525
543
|
|
|
526
|
-
bp = tooth_growth.ggplot(
|
|
527
|
-
|
|
528
|
-
R.
|
|
544
|
+
bp = tooth_growth.ggplot(
|
|
545
|
+
E.aes(x: :supp, y: :len, group: :supp)) +
|
|
546
|
+
R.geom_boxplot(E.aes(fill: :supp)) +
|
|
547
|
+
R.facet_grid(R[:all].til :dose) +
|
|
548
|
+
R.scale_fill_manual(
|
|
549
|
+
values: R.c("cyan", "deepskyblue4")) +
|
|
529
550
|
R.labs(title: "Tooth Growth: Length by Dose",
|
|
530
551
|
subtitle: "Faceted by dose",
|
|
531
552
|
x: "Delivery method", y: "Teeth length",
|
|
@@ -9,9 +9,17 @@ output:
|
|
|
9
9
|
html_document:
|
|
10
10
|
self_contained: true
|
|
11
11
|
keep_md: true
|
|
12
|
+
toc: true
|
|
13
|
+
toc_float: true
|
|
14
|
+
toc_depth: 2
|
|
15
|
+
number_sections: true
|
|
16
|
+
includes:
|
|
17
|
+
before_body: _logo_before_body.html
|
|
12
18
|
pdf_document:
|
|
13
19
|
includes:
|
|
14
|
-
in_header:
|
|
20
|
+
in_header:
|
|
21
|
+
- "../../sty/galaaz.sty"
|
|
22
|
+
- "../../sty/galaaz-headers-from-p3.tex"
|
|
15
23
|
keep_tex: yes
|
|
16
24
|
number_sections: yes
|
|
17
25
|
toc: true
|
|
@@ -21,21 +29,22 @@ fontsize: 11pt
|
|
|
21
29
|
|
|
22
30
|
|
|
23
31
|
|
|
32
|
+
|
|
33
|
+
|
|
24
34
|
According to Wikipedia "Ruby is a dynamic, interpreted, reflective, object-oriented,
|
|
25
35
|
general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro
|
|
26
36
|
"Matz" Matsumoto in Japan." It reached high popularity with the development of Ruby on Rails
|
|
27
37
|
(RoR) by David Heinemeier Hansson. RoR is a web application framework first released
|
|
28
38
|
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.
|
|
39
|
+
Ruby became very popular. According to [Ruby’s ranking in the TIOBE index](https://www.tiobe.com/tiobe-index/ruby/)
|
|
40
|
+
it **peaked** in popularity around 2008, then declined until 2015 when it started picking up again.
|
|
41
|
+
As of the original publication date (November 2018), TIOBE placed Ruby around 16th among languages.
|
|
33
42
|
|
|
34
|
-
Python,
|
|
35
|
-
|
|
43
|
+
Python, often grouped with Ruby as a high-level scripting language, ranked higher in that same snapshot.
|
|
44
|
+
Ruby is often criticized for its focus on web applications.
|
|
36
45
|
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
|
|
46
|
+
Yet, for scientific computing, Ruby lags behind Python and R. Python combines web frameworks such as
|
|
47
|
+
Django with NumPy, pandas, SciPy, and **a very large ecosystem** of domain-specific packages.
|
|
39
48
|
R is a free software environment for statistical computing and graphics with thousands
|
|
40
49
|
of libraries for data analysis.
|
|
41
50
|
|
|
@@ -53,7 +62,7 @@ Ruby and R could share one JVM runtime. That stack is **no longer** what Galaaz
|
|
|
53
62
|
today’s Galaaz is developed and tested with **JRuby or CRuby + GNU R** (see the project manual for
|
|
54
63
|
setup and command-line tools).
|
|
55
64
|
|
|
56
|
-
Library wrapping is a
|
|
65
|
+
Library wrapping is a common way to bring features from one language into another.
|
|
57
66
|
To improve performance, Python often wraps more efficient C libraries. For the
|
|
58
67
|
Python developer, the existence of such C libraries is hidden. The problem with
|
|
59
68
|
library wrapping is that for any new library, there is the need to handcraft a new
|
|
@@ -64,7 +73,7 @@ in Ruby. Doing so, all thousands of R libraries are available immediately
|
|
|
64
73
|
to Ruby developers without any new wrapping effort.
|
|
65
74
|
|
|
66
75
|
To show the power of Galaaz, we show in this article how Ruby can use R's ggplot2
|
|
67
|
-
library
|
|
76
|
+
library **transparently**, bringing to Ruby the power of high-quality scientific plotting.
|
|
68
77
|
We also show that migrating from R to Ruby with Galaaz is a matter of small
|
|
69
78
|
syntactic changes. By using Ruby, the R developer can use all of Ruby's powerful
|
|
70
79
|
object-oriented features. Also, with Ruby, it becomes much easier to move code
|
|
@@ -86,8 +95,8 @@ language and don't need special knowledge.
|
|
|
86
95
|
|
|
87
96
|
_Knitr_ is an application that converts text written in rmarkdown to many
|
|
88
97
|
different output formats. For instance, a writer can convert an rmarkdown document
|
|
89
|
-
to HTML,
|
|
90
|
-
text and _code chunks_.
|
|
98
|
+
to HTML, LaTeX, Word, and many other formats. R Markdown documents can contain
|
|
99
|
+
text and _code chunks_. knitr formats code chunks in a shaded box in the output document.
|
|
91
100
|
It also executes the code chunks and formats the output in a white box. Every line of
|
|
92
101
|
output from the execution code is preceded by '##'.
|
|
93
102
|
|
|
@@ -101,7 +110,7 @@ With _gKnit_ Ruby code chunks can share data.
|
|
|
101
110
|
# Exploring the Dataset
|
|
102
111
|
|
|
103
112
|
Let's start by exploring our selected dataset. ToothGrowth is an R dataset. A dataset
|
|
104
|
-
is like a simple
|
|
113
|
+
is like a simple Excel spreadsheet, in which each column has only one type of data.
|
|
105
114
|
For instance one column can have float, the other integer, and a third strings.
|
|
106
115
|
This dataset analyzes the length of odontoblasts (cells responsible for tooth growth)
|
|
107
116
|
in 60 guinea pigs, where each animal received one of three dose levels of Vitamin C
|
|
@@ -110,7 +119,7 @@ in 60 guinea pigs, where each animal received one of three dose levels of Vitami
|
|
|
110
119
|
|
|
111
120
|
The ToothGrowth dataset contains three columns: 'len', 'supp' and 'dose'. Let's
|
|
112
121
|
take a look at a few rows of this dataset. In Galaaz, R variables are accessed
|
|
113
|
-
by using the corresponding Ruby symbol
|
|
122
|
+
by using the corresponding Ruby symbol with the tilde (`~`) operator. Note in the
|
|
114
123
|
following chunk that 'ToothGrowth' is the R variable and Ruby's 'tooth_growth' is
|
|
115
124
|
assigned the value of '~R[:ToothGrowth]'.
|
|
116
125
|
|
|
@@ -152,7 +161,7 @@ puts tooth_growth.len.head
|
|
|
152
161
|
|
|
153
162
|
The 'dose' column contains a numeric value with either, 0.5, 1 or 2, although the
|
|
154
163
|
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
|
|
164
|
+
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
165
|
In R, the function 'as.factor' is used to convert data in a vector to factors. To use this
|
|
157
166
|
function from Galaaz the dot ('.') in the function name is substituted by '__' (double underline).
|
|
158
167
|
The function 'as.factor' becomes 'R.as__factor' or just 'as__factor' when chaining.
|
|
@@ -225,7 +234,7 @@ to form the final graphics.
|
|
|
225
234
|
In order to make a plot, we use the 'ggplot' function to the dataset. In R, this would be
|
|
226
235
|
written as ```ggplot(<dataset>, ...)```. Galaaz gives you the flexibility to use
|
|
227
236
|
either ```R.ggplot(<dataset>, ...)``` or ```<dataset>.ggplot(...)```. In the graph
|
|
228
|
-
specification
|
|
237
|
+
specification below, we use the second notation that looks more like Ruby.
|
|
229
238
|
ggplot uses the ‘aes’ method to specify
|
|
230
239
|
x and y axes; in this case, the 'dose' on the $x$ axis and the 'length' on
|
|
231
240
|
the $y$ axis: 'E.aes(x: :dose, y: :len)'. To specify the type of plot add a geom to
|
|
@@ -405,8 +414,9 @@ matches with the actual order of the colors in the plot.
|
|
|
405
414
|
|
|
406
415
|
``` ruby
|
|
407
416
|
bp = bp +
|
|
408
|
-
R.scale_fill_manual(
|
|
409
|
-
|
|
417
|
+
R.scale_fill_manual(
|
|
418
|
+
values: R.c("cyan", "deepskyblue", "deepskyblue4"),
|
|
419
|
+
breaks: R.c("2", "1", "0.5"))
|
|
410
420
|
|
|
411
421
|
puts bp
|
|
412
422
|
```
|
|
@@ -433,11 +443,13 @@ a boxplot known as a _violin plot_ with jittered data.
|
|
|
433
443
|
|
|
434
444
|
|
|
435
445
|
``` ruby
|
|
436
|
-
violin = base_tooth +
|
|
446
|
+
violin = base_tooth +
|
|
447
|
+
R.geom_violin(E.aes(fill: :dose)) +
|
|
437
448
|
R.facet_grid(R[:all].til :supp) +
|
|
438
449
|
R.geom_jitter(shape: 23, color: "cyan3", size: 1) +
|
|
439
|
-
R.scale_fill_manual(
|
|
440
|
-
|
|
450
|
+
R.scale_fill_manual(
|
|
451
|
+
values: R.c("cyan", "deepskyblue", "deepskyblue4"),
|
|
452
|
+
breaks: R.c("2", "1", "0.5"))
|
|
441
453
|
|
|
442
454
|
puts violin
|
|
443
455
|
```
|
|
@@ -502,42 +514,43 @@ written in 'bold'.
|
|
|
502
514
|
module CorpTheme
|
|
503
515
|
|
|
504
516
|
R.install_and_loads 'RColorBrewer'
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
# face
|
|
508
|
-
|
|
509
|
-
|
|
517
|
+
|
|
518
|
+
# ---------------------------------------------------------------
|
|
519
|
+
# face: 1=plain, 2=bold, 3=italic, 4=bold-italic
|
|
520
|
+
# ---------------------------------------------------------------
|
|
521
|
+
|
|
510
522
|
def self.text_element(size, face: "plain", hjust: nil)
|
|
511
|
-
E.element_text(color: "#000080",
|
|
523
|
+
E.element_text(color: "#000080",
|
|
512
524
|
face: face,
|
|
513
525
|
size: size,
|
|
514
|
-
|
|
526
|
+
hjust: hjust)
|
|
515
527
|
end
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
#
|
|
519
|
-
#
|
|
520
|
-
|
|
521
|
-
|
|
528
|
+
|
|
529
|
+
# ---------------------------------------------------------------
|
|
530
|
+
# Plot theme: no major/minor grids or borders; optional
|
|
531
|
+
# background for facets; turn off scientific notation.
|
|
532
|
+
# ---------------------------------------------------------------
|
|
533
|
+
|
|
522
534
|
def self.global_theme(faceted = false)
|
|
523
|
-
|
|
535
|
+
|
|
524
536
|
R.options(scipen: 999) # turn-off scientific notation like 1e+48
|
|
525
|
-
#
|
|
526
|
-
|
|
537
|
+
# R.theme_set(R.theme_bw)
|
|
538
|
+
|
|
527
539
|
# remove major grids
|
|
528
540
|
gb = R.theme(panel__grid__major: E.element_blank())
|
|
529
541
|
# remove minor grids
|
|
530
542
|
gb = gb + R.theme(panel__grid__minor: E.element_blank)
|
|
531
|
-
# gb = R.theme(panel__grid__minor: E.element_blank)
|
|
532
543
|
# remove border
|
|
533
544
|
gb = gb + R.theme(panel__border: E.element_blank)
|
|
534
|
-
#
|
|
535
|
-
|
|
536
|
-
|
|
545
|
+
# Keep background on faceted plots (helps separate facets)
|
|
546
|
+
if !faceted
|
|
547
|
+
gb = gb + R.theme(panel__background: E.element_blank)
|
|
548
|
+
end
|
|
537
549
|
# Change axis font
|
|
538
550
|
gb = gb + R.theme(axis__text: text_element(8))
|
|
539
551
|
# change axis title font
|
|
540
|
-
gb = gb + R.theme(
|
|
552
|
+
gb = gb + R.theme(
|
|
553
|
+
axis__title: text_element(10, face: "bold", hjust: 1))
|
|
541
554
|
# change font of title
|
|
542
555
|
gb = gb + R.theme(title: text_element(12, face: "bold"))
|
|
543
556
|
# change font of subtitle
|
|
@@ -546,7 +559,7 @@ module CorpTheme
|
|
|
546
559
|
gb = gb + R.theme(plot__caption: text_element(8))
|
|
547
560
|
|
|
548
561
|
end
|
|
549
|
-
|
|
562
|
+
|
|
550
563
|
end
|
|
551
564
|
```
|
|
552
565
|
|
|
@@ -593,9 +606,12 @@ Length of odontoblasts in 60 guinea pigs.
|
|
|
593
606
|
Each animal received one of three dose levels of vitamin C.
|
|
594
607
|
EOT
|
|
595
608
|
|
|
596
|
-
bp = tooth_growth.ggplot(
|
|
597
|
-
|
|
598
|
-
R.
|
|
609
|
+
bp = tooth_growth.ggplot(
|
|
610
|
+
E.aes(x: :supp, y: :len, group: :supp)) +
|
|
611
|
+
R.geom_boxplot(E.aes(fill: :supp)) +
|
|
612
|
+
R.facet_grid(R[:all].til :dose) +
|
|
613
|
+
R.scale_fill_manual(
|
|
614
|
+
values: R.c("cyan", "deepskyblue4")) +
|
|
599
615
|
R.labs(title: "Tooth Growth: Length by Dose",
|
|
600
616
|
subtitle: "Faceted by dose",
|
|
601
617
|
x: "Delivery method", y: "Teeth length",
|