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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -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 +51 -10
  73. data/script/omarchy/README.md +1 -1
  74. data/script/omarchy/galaaz-guide.sh +1 -1
  75. data/sty/galaaz.sty +22 -0
  76. data/version.rb +1 -1
  77. metadata +19 -1
@@ -165,6 +165,28 @@
165
165
  % Command to import an R variable to latex
166
166
  \newcommand{\RtoLatex}[2]{\newcommand{#1}{#2}}
167
167
 
168
+ % Soft-wrap Pandoc highlighted code/output boxes (Shaded + Highlighting).
169
+ % This runs after Pandoc's default \DefineVerbatimEnvironment{Highlighting}
170
+ % (header includes come later in the generated .tex). Prefer manual line
171
+ % breaks in Rmd sources; breaklines is a safety net for leftovers/output.
172
+ % Requires TinyTeX/TeX Live package: tlmgr install fvextra
173
+ \IfFileExists{fvextra.sty}{%
174
+ \usepackage{fvextra}%
175
+ \DefineVerbatimEnvironment{Highlighting}{Verbatim}{%
176
+ breaklines=true,
177
+ breakanywhere=true,
178
+ breakindent=1.5em,
179
+ fontsize=\small,
180
+ commandchars=\\\{\}%
181
+ }%
182
+ }{%
183
+ % fancyvrb is already loaded by Pandoc; shrink code so more fits per line.
184
+ \DefineVerbatimEnvironment{Highlighting}{Verbatim}{%
185
+ fontsize=\small,
186
+ commandchars=\\\{\}%
187
+ }%
188
+ }
189
+
168
190
  %
169
191
  %\newcommand{\atraso}[1]{\color{red} \textbf {Tempo desde a Assinatura do Contrato: #1 dias}}
170
192
  \usepackage{bookmark}
@@ -183,8 +205,8 @@
183
205
  \apptocmd{\@title}{\par {\large #1 \par}}{}{}
184
206
  }
185
207
  \makeatother
186
- \subtitle{An example of tightly coupling Ruby and R (JRuby + GNU R,
187
- Galaaz 2.0)}
208
+ \subtitle{An example of tightly coupling Ruby and R (JRuby or CRuby +
209
+ GNU R, Galaaz 2.0)}
188
210
  \author{Rodrigo Botafogo}
189
211
  \date{16 October 2018 (narrative updated for Galaaz 2.0, 2026)}
190
212
 
@@ -202,22 +224,23 @@ language, with a large community, a very large set of libraries and
202
224
  great for web development. However, it lacks libraries for data science,
203
225
  statistics, scientific plotting and machine learning. On the other hand,
204
226
  R is considered one of the most powerful languages for solving all of
205
- the above problems. Maybe the strongest competitor to R is Python with
206
- libraries such as NumPy, Panda, SciPy, SciKit-Learn and a couple more.
227
+ the above problems. \textbf{Python} is a strong competitor: NumPy,
228
+ pandas, SciPy, and scikit-learn are widely used examples among
229
+ \textbf{many thousands} of packages on PyPI for numerical and ML work.
207
230
 
208
231
  With Galaaz we do not intend to re-implement any of the scientific
209
232
  libraries in R; we allow for very tight coupling between the two
210
233
  languages to the point that the Ruby developer does not need to think
211
234
  about R syntax for every call. \textbf{Galaaz 2.0} does this with
212
- \textbf{\href{https://www.jruby.org/}{JRuby}} and \textbf{GNU R}: a
213
- \textbf{bridge} evaluates R from Ruby and exchanges data between
214
- processes.
235
+ \textbf{\href{https://www.jruby.org/}{JRuby}} or \textbf{CRuby} and
236
+ \textbf{GNU R}: a \textbf{bridge} evaluates R from Ruby and exchanges
237
+ data between processes.
215
238
 
216
239
  An \textbf{earlier} Galaaz prototype used Oracle's \textbf{GraalVM} with
217
240
  \textbf{TruffleRuby} and \textbf{FastR} in one JVM. That stack is
218
241
  \textbf{historical}; today's documentation and tooling assume
219
- \textbf{JRuby + GNU R} (see the project manual and
220
- \textbf{\texttt{bin/galaaz-jruby}} / \textbf{\texttt{bin/gknit}}).
242
+ \textbf{NewBridge on JRuby or CRuby} (see the project manual and
243
+ \textbf{\texttt{bin/galaaz-ruby}} / \textbf{\texttt{bin/gknit}}).
221
244
 
222
245
  For background on the old stack:
223
246
 
@@ -258,7 +281,8 @@ Arthurian legend.
258
281
  \begin{itemize}
259
282
  \tightlist
260
283
  \item
261
- \textbf{JRuby} and a compatible \textbf{JDK}
284
+ \textbf{JRuby} and a compatible \textbf{JDK}, \emph{or} \textbf{CRuby
285
+ 3.3+}
262
286
  \item
263
287
  \textbf{GNU R} on your \texttt{PATH}
264
288
  \end{itemize}
@@ -274,9 +298,9 @@ but could be installed prior to the demo if desired:
274
298
  gridExtra
275
299
  \end{itemize}
276
300
 
277
- Installation of R packages requires a development environment. In Linux,
278
- the gnu compiler and tools should be enough. I am not sure what is
279
- needed on the Mac.
301
+ Installation of R packages requires a development environment. On Linux,
302
+ a typical build toolchain (GCC, headers) is usually enough. On macOS,
303
+ Apple's \textbf{Xcode Command Line Tools} are commonly required.
280
304
 
281
305
  In order to run the `specs' the following Ruby package is necessary:
282
306
 
@@ -296,38 +320,38 @@ In order to run the `specs' the following Ruby package is necessary:
296
320
 
297
321
  \subsection{Running the demo}\label{running-the-demo}
298
322
 
299
- The ggplot for this demos was extracted from:
323
+ The ggplot examples for this demo were adapted from:
300
324
  \url{http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html}.
301
325
 
302
- On the console do
326
+ At the shell, from a suitable Galaaz environment:
303
327
 
304
328
  \begin{verbatim}
305
- > galaaz master_list:scatter_plot
329
+ galaaz master_list:scatter_plot
306
330
  \end{verbatim}
307
331
 
308
332
  \subsection{Running other demos}\label{running-other-demos}
309
333
 
310
- Doing on the console
334
+ Running
311
335
 
312
336
  \begin{verbatim}
313
- > galaaz -T
337
+ galaaz -T
314
338
  \end{verbatim}
315
339
 
316
- will show a list with all available demos. To run any of the demos in
317
- the list, substitute the call to `rake' to `galaaz'. For instance, one
318
- of the examples in the list is `rake sthda:bar'. In order to run this
319
- example just do `galaaz sthda:bar'. Doing `galaaz sthda:all' will run
320
- all demos in the sthda cathegory. Some of the examples require `rspec'
321
- do be available. To install `rspec' just do `gem install rspec'.
340
+ lists available demo tasks. To run a demo, use \textbf{\texttt{galaaz}}
341
+ where you would otherwise invoke \textbf{\texttt{rake}}. For example, if
342
+ the list shows \texttt{rake\ sthda:bar}, run \texttt{galaaz\ sthda:bar}.
343
+ To run every demo in the \textbf{sthda} category, use
344
+ \texttt{galaaz\ sthda:all}. Some examples require \textbf{rspec};
345
+ install it with \texttt{gem\ install\ rspec}.
322
346
 
323
347
  \section{The demo code}\label{the-demo-code}
324
348
 
325
349
  The following is the Ruby code and plot for the above example. There is
326
- a small difference between the code in the example and the code bellow.
327
- If the example is ran, the plot will appear on the screen, bellow, we
328
- generate an `svg' image and then include it in this document. In order
329
- to generate and image, the R.svg device is used. To generate the plot on
330
- the screen, use the R.awt device, as commented on the code.
350
+ a small difference between the code in the example and the code below.
351
+ If the example is \textbf{run}, the plot will appear on the screen;
352
+ below, we generate an SVG image and then include it in this document. In
353
+ order to generate and image, the R.svg device is used. To generate the
354
+ plot on the screen, use the R.awt device, as commented on the code.
331
355
 
332
356
  \begin{Shaded}
333
357
  \begin{Highlighting}[]
@@ -338,7 +362,7 @@ the screen, use the R.awt device, as commented on the code.
338
362
  \ConstantTok{R}\AttributeTok{.options}\NormalTok{(}\WarningTok{scipen:} \DecValTok{999}\NormalTok{) }\CommentTok{\# turn{-}off scientific notation like 1e+48}
339
363
  \ConstantTok{R}\AttributeTok{.theme\_set}\NormalTok{(}\ConstantTok{R}\AttributeTok{.theme\_bw}\NormalTok{) }\CommentTok{\# pre{-}set the bw theme.}
340
364
 
341
- \NormalTok{midwest }\OperatorTok{=} \OperatorTok{\textasciitilde{}}\WarningTok{:midwest}
365
+ \NormalTok{midwest }\OperatorTok{=} \OperatorTok{\textasciitilde{}}\ConstantTok{R}\KeywordTok{[}\WarningTok{:midwest}\KeywordTok{]}
342
366
 
343
367
  \CommentTok{\# Scatterplot}
344
368
  \NormalTok{gg }\OperatorTok{=}\NormalTok{ midwest}\AttributeTok{.ggplot}\NormalTok{(}\ConstantTok{E}\AttributeTok{.aes}\NormalTok{(}\WarningTok{x:} \WarningTok{:area}\NormalTok{, }\WarningTok{y:} \WarningTok{:poptotal}\NormalTok{)) }\OperatorTok{+}
@@ -356,7 +380,7 @@ the screen, use the R.awt device, as commented on the code.
356
380
  \end{Highlighting}
357
381
  \end{Shaded}
358
382
 
359
- \pandocbounded{\includegraphics[keepaspectratio]{galaaz_ggplot_files/figure-latex/midwest_rb.pdf}}
383
+ \pandocbounded{\includegraphics[keepaspectratio]{galaaz_ggplot_files/galaaz_ggplot_files/figure-latex/midwest_rb.pdf}}
360
384
 
361
385
  In R, the code to generate this plot is the following
362
386
 
@@ -428,38 +452,43 @@ notation and the preferred color is blue.
428
452
  \begin{Highlighting}[]
429
453
  \CommentTok{\# corp\_theme.rb}
430
454
  \CommentTok{\# defines the corporate theme for all plots}
431
-
455
+
432
456
  \ControlFlowTok{module} \DataTypeTok{CorpTheme}
433
457
 
434
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
435
- \CommentTok{\# Defines the plot theme (visualization). In this theme we remove major and minor}
436
- \CommentTok{\# grids, borders and background. We also turn{-}off scientific notation.}
437
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
438
-
458
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
459
+ \CommentTok{\# Plot theme: no major/minor grids, borders, or background;}
460
+ \CommentTok{\# turn off scientific notation.}
461
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
462
+
439
463
  \ControlFlowTok{def} \DecValTok{self}\AttributeTok{.global\_theme}
440
-
464
+
441
465
  \ConstantTok{R}\AttributeTok{.options}\NormalTok{(}\WarningTok{scipen:} \DecValTok{999}\NormalTok{) }\CommentTok{\# turn{-}off scientific notation like 1e+48}
442
-
466
+
443
467
  \CommentTok{\# remove major grids}
444
- \NormalTok{ global\_theme }\OperatorTok{=} \ConstantTok{R}\AttributeTok{.theme}\NormalTok{(}\WarningTok{panel\_\_grid\_\_major:} \ConstantTok{E}\AttributeTok{.element\_blank}\NormalTok{())}
468
+ \NormalTok{ global\_theme }\OperatorTok{=}
469
+ \ConstantTok{R}\AttributeTok{.theme}\NormalTok{(}\WarningTok{panel\_\_grid\_\_major:} \ConstantTok{E}\AttributeTok{.element\_blank}\NormalTok{())}
445
470
  \CommentTok{\# remove minor grids}
446
- \NormalTok{ global\_theme }\OperatorTok{=}\NormalTok{ global\_theme }\OperatorTok{+} \ConstantTok{R}\AttributeTok{.theme}\NormalTok{(}\WarningTok{panel\_\_grid\_\_minor:} \ConstantTok{E}\AttributeTok{.element\_blank}\NormalTok{)}
471
+ \NormalTok{ global\_theme }\OperatorTok{=}\NormalTok{ global\_theme }\OperatorTok{+}
472
+ \ConstantTok{R}\AttributeTok{.theme}\NormalTok{(}\WarningTok{panel\_\_grid\_\_minor:} \ConstantTok{E}\AttributeTok{.element\_blank}\NormalTok{)}
447
473
  \CommentTok{\# remove border}
448
- \NormalTok{ global\_theme }\OperatorTok{=}\NormalTok{ global\_theme }\OperatorTok{+} \ConstantTok{R}\AttributeTok{.theme}\NormalTok{(}\WarningTok{panel\_\_border:} \ConstantTok{E}\AttributeTok{.element\_blank}\NormalTok{)}
474
+ \NormalTok{ global\_theme }\OperatorTok{=}\NormalTok{ global\_theme }\OperatorTok{+}
475
+ \ConstantTok{R}\AttributeTok{.theme}\NormalTok{(}\WarningTok{panel\_\_border:} \ConstantTok{E}\AttributeTok{.element\_blank}\NormalTok{)}
449
476
  \CommentTok{\# remove background}
450
- \NormalTok{ global\_theme }\OperatorTok{=}\NormalTok{ global\_theme }\OperatorTok{+} \ConstantTok{R}\AttributeTok{.theme}\NormalTok{(}\WarningTok{panel\_\_background:} \ConstantTok{E}\AttributeTok{.element\_blank}\NormalTok{)}
477
+ \NormalTok{ global\_theme }\OperatorTok{=}\NormalTok{ global\_theme }\OperatorTok{+}
478
+ \ConstantTok{R}\AttributeTok{.theme}\NormalTok{(}\WarningTok{panel\_\_background:} \ConstantTok{E}\AttributeTok{.element\_blank}\NormalTok{)}
451
479
  \CommentTok{\# Change axis font}
452
480
  \NormalTok{ global\_theme }\OperatorTok{=}\NormalTok{ global\_theme }\OperatorTok{+}
453
- \ConstantTok{R}\AttributeTok{.theme}\NormalTok{(}\WarningTok{axis\_\_text:} \ConstantTok{E}\AttributeTok{.element\_text}\NormalTok{(}\WarningTok{size:} \DecValTok{8}\NormalTok{, }\WarningTok{color:} \StringTok{"\#000080"}\NormalTok{))}
481
+ \ConstantTok{R}\AttributeTok{.theme}\NormalTok{(}\WarningTok{axis\_\_text:} \ConstantTok{E}\AttributeTok{.element\_text}\NormalTok{(}
482
+ \WarningTok{size:} \DecValTok{8}\NormalTok{, }\WarningTok{color:} \StringTok{"\#000080"}\NormalTok{))}
454
483
  \CommentTok{\# change color of axis titles}
455
484
  \NormalTok{ global\_theme }\OperatorTok{=}\NormalTok{ global\_theme }\OperatorTok{+}
456
- \ConstantTok{R}\AttributeTok{.theme}\NormalTok{(}\WarningTok{axis\_\_title:} \ConstantTok{E}\AttributeTok{.element\_text}\NormalTok{(}
457
- \WarningTok{color:} \StringTok{"\#000080"}\NormalTok{, }
458
- \WarningTok{face:} \StringTok{"bold"}\NormalTok{,}
459
- \WarningTok{size:} \DecValTok{8}\NormalTok{,}
460
- \WarningTok{hjust:} \DecValTok{1}\NormalTok{))}
485
+ \ConstantTok{R}\AttributeTok{.theme}\NormalTok{(}\WarningTok{axis\_\_title:} \ConstantTok{E}\AttributeTok{.element\_text}\NormalTok{(}
486
+ \WarningTok{color:} \StringTok{"\#000080"}\NormalTok{,}
487
+ \WarningTok{face:} \StringTok{"bold"}\NormalTok{,}
488
+ \WarningTok{size:} \DecValTok{8}\NormalTok{,}
489
+ \WarningTok{hjust:} \DecValTok{1}\NormalTok{))}
461
490
  \ControlFlowTok{end}
462
-
491
+
463
492
  \ControlFlowTok{end}
464
493
  \end{Highlighting}
465
494
  \end{Shaded}
@@ -470,7 +499,7 @@ We now define a ScatterPlot class:
470
499
  \begin{Highlighting}[]
471
500
  \CommentTok{\# ScatterPlot.rb}
472
501
  \CommentTok{\# creates a scatter plot and allow some configuration}
473
-
502
+
474
503
  \ControlFlowTok{class} \DataTypeTok{ScatterPlot}
475
504
 
476
505
  \OtherTok{attr\_accessor} \WarningTok{:title}
@@ -478,55 +507,55 @@ We now define a ScatterPlot class:
478
507
  \OtherTok{attr\_accessor} \WarningTok{:caption}
479
508
  \OtherTok{attr\_accessor} \WarningTok{:x\_label}
480
509
  \OtherTok{attr\_accessor} \WarningTok{:y\_label}
481
-
482
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
510
+
511
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
483
512
  \CommentTok{\# Initialize the plot with the data and the x and y variables}
484
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
513
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
485
514
 
486
515
  \ControlFlowTok{def}\NormalTok{ initialize(data, x}\OperatorTok{:}\NormalTok{, }\WarningTok{y:}\NormalTok{)}
487
516
  \OtherTok{@data} \OperatorTok{=}\NormalTok{ data}
488
517
  \OtherTok{@x} \OperatorTok{=}\NormalTok{ x}
489
518
  \OtherTok{@y} \OperatorTok{=}\NormalTok{ y}
490
519
  \ControlFlowTok{end}
491
-
492
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
520
+
521
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
493
522
  \CommentTok{\# Define groupings by color and size}
494
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
523
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
495
524
 
496
525
  \ControlFlowTok{def}\NormalTok{ group\_by(color}\OperatorTok{:}\NormalTok{, }\WarningTok{size:}\NormalTok{)}
497
526
  \OtherTok{@color\_by} \OperatorTok{=}\NormalTok{ color}
498
527
  \OtherTok{@size\_by} \OperatorTok{=}\NormalTok{ size}
499
528
  \ControlFlowTok{end}
500
529
 
501
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
502
- \CommentTok{\# Add a smoothing line, and if confidence is true the add a confidence interval, if}
503
- \CommentTok{\# false does not add the confidence interval}
504
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
530
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
531
+ \CommentTok{\# Add a smoothing line; confidence: true draws a CI band.}
532
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
505
533
 
506
534
  \ControlFlowTok{def}\NormalTok{ add\_smoothing\_line(method}\OperatorTok{:}\NormalTok{, }\WarningTok{confidence:} \DecValTok{true}\NormalTok{)}
507
535
  \OtherTok{@method} \OperatorTok{=}\NormalTok{ method}
508
536
  \OtherTok{@confidence} \OperatorTok{=}\NormalTok{ confidence}
509
537
  \ControlFlowTok{end}
510
-
511
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
512
- \CommentTok{\# Creates the graph title, properly formated for this theme}
513
- \CommentTok{\# @param title [String] The title to add to the graph}
514
- \CommentTok{\# @return textGrob that can be included in a graph}
515
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
516
-
517
- \ControlFlowTok{def}\NormalTok{ graph\_params(title}\OperatorTok{:} \StringTok{""}\NormalTok{, }\WarningTok{subtitle:} \StringTok{""}\NormalTok{, }\WarningTok{caption:} \StringTok{""}\NormalTok{, }\WarningTok{x\_label:} \StringTok{""}\NormalTok{, }\WarningTok{y\_label:} \StringTok{""}\NormalTok{)}
538
+
539
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
540
+ \CommentTok{\# Graph title / labels, formatted for this theme.}
541
+ \CommentTok{\# @param title [String] title to add to the graph}
542
+ \CommentTok{\# @return labs() result that can be included in a graph}
543
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
544
+
545
+ \ControlFlowTok{def}\NormalTok{ graph\_params(title}\OperatorTok{:} \StringTok{""}\NormalTok{, }\WarningTok{subtitle:} \StringTok{""}\NormalTok{, }\WarningTok{caption:} \StringTok{""}\NormalTok{,}
546
+ \WarningTok{x\_label:} \StringTok{""}\NormalTok{, }\WarningTok{y\_label:} \StringTok{""}\NormalTok{)}
518
547
  \ConstantTok{R}\AttributeTok{.labs}\NormalTok{(}
519
- \WarningTok{title:}\NormalTok{ title, }
520
- \WarningTok{subtitle:}\NormalTok{ subtitle, }
548
+ \WarningTok{title:}\NormalTok{ title,}
549
+ \WarningTok{subtitle:}\NormalTok{ subtitle,}
521
550
  \WarningTok{caption:}\NormalTok{ caption,}
522
- \WarningTok{y\_label:}\NormalTok{ y\_label, }
523
- \WarningTok{x\_label:}\NormalTok{ x\_label, }
551
+ \WarningTok{y\_label:}\NormalTok{ y\_label,}
552
+ \WarningTok{x\_label:}\NormalTok{ x\_label,}
524
553
  \NormalTok{ )}
525
554
  \ControlFlowTok{end}
526
555
 
527
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
556
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
528
557
  \CommentTok{\# Prepare the plot\textquotesingle{}s points}
529
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
558
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
530
559
 
531
560
  \ControlFlowTok{def}\NormalTok{ points}
532
561
  \NormalTok{ params }\OperatorTok{=} \OperatorTok{\{\}}
@@ -534,28 +563,27 @@ We now define a ScatterPlot class:
534
563
  \NormalTok{ params}\KeywordTok{[}\WarningTok{:size}\KeywordTok{]} \OperatorTok{=} \OtherTok{@size\_by} \ControlFlowTok{if} \OtherTok{@size\_by}
535
564
  \ConstantTok{R}\AttributeTok{.geom\_point}\NormalTok{(}\ConstantTok{E}\AttributeTok{.aes}\NormalTok{(params))}
536
565
  \ControlFlowTok{end}
537
-
538
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
566
+
567
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
539
568
  \CommentTok{\# Plots the scatterplot}
540
- \CommentTok{\#{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
569
+ \CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
541
570
 
542
571
  \ControlFlowTok{def}\NormalTok{ plot}
543
572
  \NormalTok{ gg }\OperatorTok{=} \OtherTok{@data}\AttributeTok{.ggplot}\NormalTok{(}\ConstantTok{E}\AttributeTok{.aes}\NormalTok{(}\WarningTok{x:} \OtherTok{@x}\NormalTok{, }\WarningTok{y:} \OtherTok{@y}\NormalTok{)) }\OperatorTok{+}
544
- \NormalTok{ points }\OperatorTok{+}
573
+ \NormalTok{ points }\OperatorTok{+}
545
574
  \ConstantTok{R}\AttributeTok{.geom\_smooth}\NormalTok{(}\WarningTok{method:} \OtherTok{@method}\NormalTok{, }\WarningTok{se:} \OtherTok{@confidence}\NormalTok{) }\OperatorTok{+}
546
575
  \ConstantTok{R}\AttributeTok{.xlim}\NormalTok{(}\ConstantTok{R}\AttributeTok{.c}\NormalTok{(}\DecValTok{0}\NormalTok{, }\FloatTok{0.1}\NormalTok{)) }\OperatorTok{+}
547
- \ConstantTok{R}\AttributeTok{.ylim}\NormalTok{(}\ConstantTok{R}\AttributeTok{.c}\NormalTok{(}\DecValTok{0}\NormalTok{, }\DecValTok{500000}\NormalTok{)) }\OperatorTok{+}
576
+ \ConstantTok{R}\AttributeTok{.ylim}\NormalTok{(}\ConstantTok{R}\AttributeTok{.c}\NormalTok{(}\DecValTok{0}\NormalTok{, }\DecValTok{500000}\NormalTok{)) }\OperatorTok{+}
548
577
  \NormalTok{ graph\_params(}\WarningTok{title:} \OtherTok{@title}\NormalTok{,}
549
- \WarningTok{subtitle:} \OtherTok{@subtitle}\NormalTok{, }
550
- \WarningTok{y\_label:} \OtherTok{@y\_label}\NormalTok{, }
551
- \WarningTok{x\_label:} \OtherTok{@x\_label}\NormalTok{, }
578
+ \WarningTok{subtitle:} \OtherTok{@subtitle}\NormalTok{,}
579
+ \WarningTok{y\_label:} \OtherTok{@y\_label}\NormalTok{,}
580
+ \WarningTok{x\_label:} \OtherTok{@x\_label}\NormalTok{,}
552
581
  \WarningTok{caption:} \OtherTok{@caption}\NormalTok{) }\OperatorTok{+}
553
582
  \DataTypeTok{CorpTheme}\AttributeTok{.global\_theme}
554
583
 
555
584
  \FunctionTok{puts}\NormalTok{ gg}
556
-
557
585
  \ControlFlowTok{end}
558
-
586
+
559
587
  \ControlFlowTok{end}
560
588
  \end{Highlighting}
561
589
  \end{Shaded}
@@ -568,29 +596,31 @@ data
568
596
  \FunctionTok{require} \VerbatimStringTok{\textquotesingle{}galaaz\textquotesingle{}}
569
597
  \FunctionTok{require} \VerbatimStringTok{\textquotesingle{}ggplot\textquotesingle{}}
570
598
 
571
- \NormalTok{sp }\OperatorTok{=} \DataTypeTok{ScatterPlot}\AttributeTok{.new}\NormalTok{(}\OperatorTok{\textasciitilde{}}\WarningTok{:midwest}\NormalTok{, }\WarningTok{x:} \WarningTok{:area}\NormalTok{, }\WarningTok{y:} \WarningTok{:poptotal}\NormalTok{)}
599
+ \NormalTok{sp }\OperatorTok{=} \DataTypeTok{ScatterPlot}\AttributeTok{.new}\NormalTok{(}\OperatorTok{\textasciitilde{}}\ConstantTok{R}\KeywordTok{[}\WarningTok{:midwest}\KeywordTok{]}\NormalTok{, }\WarningTok{x:} \WarningTok{:area}\NormalTok{, }\WarningTok{y:} \WarningTok{:poptotal}\NormalTok{)}
572
600
  \NormalTok{sp}\AttributeTok{.title} \OperatorTok{=} \StringTok{"Midwest Dataset {-} Scatterplot"}
573
601
  \NormalTok{sp}\AttributeTok{.subtitle} \OperatorTok{=} \StringTok{"Area Vs Population"}
574
602
  \NormalTok{sp}\AttributeTok{.caption} \OperatorTok{=} \StringTok{"Source: midwest"}
575
603
  \NormalTok{sp}\AttributeTok{.x\_label} \OperatorTok{=} \StringTok{"Area"}
576
604
  \NormalTok{sp}\AttributeTok{.y\_label} \OperatorTok{=} \StringTok{"Population"}
577
- \NormalTok{sp}\AttributeTok{.group\_by}\NormalTok{(}\WarningTok{color:} \WarningTok{:state}\NormalTok{, }\WarningTok{size:} \WarningTok{:popdensity}\NormalTok{) }\CommentTok{\# try sp.group\_by(color: :state)}
605
+ \CommentTok{\# try: sp.group\_by(color: :state)}
606
+ \NormalTok{sp}\AttributeTok{.group\_by}\NormalTok{(}\WarningTok{color:} \WarningTok{:state}\NormalTok{, }\WarningTok{size:} \WarningTok{:popdensity}\NormalTok{)}
578
607
  \CommentTok{\# available methods: "lm", "glm", "loess", "gam"}
579
- \NormalTok{sp}\AttributeTok{.add\_smoothing\_line}\NormalTok{(}\WarningTok{method:} \StringTok{"glm"}\NormalTok{) }
608
+ \NormalTok{sp}\AttributeTok{.add\_smoothing\_line}\NormalTok{(}\WarningTok{method:} \StringTok{"glm"}\NormalTok{)}
580
609
  \NormalTok{sp}\AttributeTok{.plot}
581
610
  \end{Highlighting}
582
611
  \end{Shaded}
583
612
 
584
- \pandocbounded{\includegraphics[keepaspectratio]{galaaz_ggplot_files/figure-latex/scatter_plot_rb.pdf}}
613
+ \pandocbounded{\includegraphics[keepaspectratio]{galaaz_ggplot_files/galaaz_ggplot_files/figure-latex/scatter_plot_rb.pdf}}
585
614
 
586
615
  \section{Conclusion}\label{conclusion}
587
616
 
588
617
  R is a very powerful language for statistical analysis, data analytics,
589
618
  machine learning, plotting and many other scientific applications with a
590
619
  very large package ecosystem. However R is often considered hard to
591
- learn and lacking modern computer languages constructs such as object
592
- oriented classes, modules, lambdas, etc. For this reason, many
593
- developers have started or switched from R to Python.
620
+ learn and lacking modern language features such as object-oriented
621
+ classes, modules, and first-class functions. For that reason, many teams
622
+ have standardized on Python (or stayed entirely inside R) rather than
623
+ mixing ecosystems.
594
624
 
595
625
  With Galaaz, R programmers can almost transparently migrate from R to
596
626
  Ruby, since syntax is almost identical and \textbf{GNU R} remains the
@@ -601,7 +631,8 @@ libraries that nicely complement R packages.
601
631
  For the Ruby developer, Galaaz allows the immediate use of R functions
602
632
  with minimal ceremony. As shown in the second example above, class
603
633
  \texttt{ScatterPlot} hides most R call details from the Ruby developer.
604
- \textbf{JRuby} provides \textbf{real parallel threads} on the Ruby side
605
- and access to the JVM ecosystem when you need it.
634
+ Prefer \textbf{JRuby} when you want \textbf{real parallel threads} on
635
+ the Ruby side and access to the JVM ecosystem; \textbf{CRuby} works
636
+ equally for the Galaaz bridge itself.
606
637
 
607
638
  \end{document}
@@ -10,6 +10,7 @@ output:
10
10
  pdf_document:
11
11
  includes:
12
12
  in_header: ["../../sty/galaaz.sty"]
13
+ keep_tex: yes
13
14
  number_sections: yes
14
15
  html_document:
15
16
  self_contained: true
@@ -18,7 +19,7 @@ biblio-style: apsr
18
19
  ---
19
20
 
20
21
  ```{r setup, echo=FALSE}
21
-
22
+ options(width = 70)
22
23
  ```
23
24
 
24
25
  # Introduction
@@ -305,15 +306,17 @@ a linear regression line (method = "lm") for every manufacturer.
305
306
  library(ggplot2)
306
307
  data(mpg, package="ggplot2")
307
308
 
308
- mpg_select <- mpg[mpg$manufacturer %in% c("audi", "ford", "honda", "hyundai"), ]
309
+ mpg_select <- mpg[
310
+ mpg$manufacturer %in% c("audi", "ford", "honda", "hyundai"),
311
+ ]
309
312
 
310
313
  # Scatterplot
311
314
  theme_set(theme_bw()) # pre-set the bw theme.
312
- g <- ggplot(mpg_select, aes(displ, cty)) +
315
+ g <- ggplot(mpg_select, aes(displ, cty)) +
313
316
  labs(subtitle="mpg: Displacement vs City Mileage",
314
317
  title="Bubble chart")
315
318
 
316
- g + geom_jitter(aes(col=manufacturer, size=hwy)) +
319
+ g + geom_jitter(aes(col=manufacturer, size=hwy)) +
317
320
  geom_smooth(aes(col=manufacturer), method="lm", se=F)
318
321
  ```
319
322
 
@@ -411,42 +414,43 @@ ten aspects are:
411
414
  # copy the R variable :mtcars to the Ruby mtcars variable
412
415
  mtcars = ~R[:mtcars]
413
416
 
414
- # create a new column 'car_name' to store the car names so that it can be
415
- # used for plotting. The 'rownames' of the data frame cannot be used as
416
- # data for plotting
417
+ # New column 'car_name' for plotting (rownames alone are not
418
+ # usable as plot data).
417
419
  mtcars.car_name = R.rownames(:mtcars)
418
420
 
419
- # compute normalized mpg and add it to a new column called mpg_z
420
- # Note that the mean value for mpg can be obtained by calling the 'mean'
421
- # function on the vector 'mtcars.mpg'. The same with the standard
422
- # deviation 'sd'. The vector is then rounded to two digits with 'round 2'
423
- mtcars.mpg_z = ((mtcars.mpg - mtcars.mpg.mean)/mtcars.mpg.sd).round 2
421
+ # Normalized mpg in column mpg_z: (mpg - mean) / sd, rounded.
422
+ mtcars.mpg_z =
423
+ ((mtcars.mpg - mtcars.mpg.mean) / mtcars.mpg.sd).round 2
424
424
 
425
- # create a new column 'mpg_type'. Function 'ifelse' is a vectorized function
426
- # that looks at every element of the mpg_z vector and if the value is below
427
- # 0, returns 'below', otherwise returns 'above'
428
- mtcars.mpg_type = (mtcars.mpg_z < 0).ifelse("below", "above")
425
+ # mpg_type: 'below' if mpg_z < 0, else 'above' (vectorized ifelse).
426
+ mtcars.mpg_type =
427
+ (mtcars.mpg_z < 0).ifelse("below", "above")
429
428
 
430
- # order the mtcar data set by the mpg_z vector from smaler to larger values
429
+ # Order rows by mpg_z ascending.
431
430
  mtcars = mtcars[mtcars.mpg_z.order, :all]
432
431
 
433
- # convert the car_name column to a factor to retain sorted order in plot
434
- mtcars.car_name = mtcars.car_name.factor levels: mtcars.car_name
432
+ # Factor car_name so plot keeps sorted order.
433
+ mtcars.car_name =
434
+ mtcars.car_name.factor levels: mtcars.car_name
435
435
 
436
- # let's look at the first records of the final data frame
436
+ # First records of the final data frame
437
437
  puts mtcars.head
438
438
  ```
439
439
 
440
440
  ```{ruby diverging_bar, fig.width = 9.1, fig.height = 6.5}
441
441
  require 'ggplot'
442
442
 
443
- puts mtcars.ggplot(E.aes(x: :car_name, y: :mpg_z, label: :mpg_z)) +
444
- R.geom_bar(E.aes(fill: :mpg_type), stat: 'identity', width: 0.5) +
445
- R.scale_fill_manual(name: 'Mileage',
446
- labels: R.c('Above Average', 'Below Average'),
447
- values: R.c('above': '#00ba38', 'below': '#f8766d')) +
443
+ puts mtcars.ggplot(
444
+ E.aes(x: :car_name, y: :mpg_z, label: :mpg_z)) +
445
+ R.geom_bar(E.aes(fill: :mpg_type),
446
+ stat: 'identity', width: 0.5) +
447
+ R.scale_fill_manual(
448
+ name: 'Mileage',
449
+ labels: R.c('Above Average', 'Below Average'),
450
+ values: R.c('above': '#00ba38',
451
+ 'below': '#f8766d')) +
448
452
  R.labs(subtitle: "Normalised mileage from 'mtcars'",
449
- title: "Diverging Bars") +
453
+ title: "Diverging Bars") +
450
454
  R.coord_flip
451
455
  ```
452
456
 
@@ -459,7 +463,8 @@ with the 'rb' engine. The following chunk specification will
459
463
  create and inline Ruby text:
460
464
 
461
465
  ````
462
- This is some text with inline Ruby accessing variable 'b' which has value:
466
+ This is some text with inline Ruby accessing
467
+ variable 'b' which has value:
463
468
  ```{rb puts "```{rb puts b}\n```"}
464
469
  ```
465
470
  and is followed by some other text!
@@ -658,7 +663,7 @@ the Yaml header to generate this blog in PDF format instead of HTML:
658
663
 
659
664
  ```
660
665
  ---
661
- title: "gKnit - Ruby and R Knitting with Galaaz (JRuby or CRuby + GNU R)"
666
+ title: "gKnit - Ruby and R Knitting with Galaaz"
662
667
  author: "Rodrigo Botafogo"
663
668
  tags: [Galaaz, Ruby, R, JRuby, CRuby, "GNU R", knitr, gknit]
664
669
  date: "29 October 2018"