galaaz 0.4.2 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +25 -0
- data/Rakefile +8 -0
- data/bin/gknit +9 -5
- data/bin/gstudio +4 -2
- data/bin/gstudio.rb +32 -2
- data/blogs/dev/dev.html +219 -34
- data/blogs/dev/dev.md +26 -26
- data/blogs/dev/dev_files/figure-html/bubble-1.png +0 -0
- data/blogs/dev/dev_files/figure-html/diverging_bar.png +0 -0
- data/blogs/dplyr/dplyr.rb +63 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +38 -26
- data/blogs/galaaz_ggplot/galaaz_ggplot.aux +16 -17
- data/blogs/galaaz_ggplot/galaaz_ggplot.pdf +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.tex +65 -31
- data/blogs/oh_my/not_so.rb +2342 -0
- data/blogs/oh_my/oh_my.Rmd +493 -0
- data/blogs/oh_my/oh_my.html +680 -0
- data/blogs/oh_my/oh_my.md +597 -0
- data/blogs/oh_my/old.Rmd +2100 -0
- data/blogs/ruby_plot/figures/facets_with_decorations.png +0 -0
- data/blogs/ruby_plot/figures/facets_with_jitter.png +0 -0
- data/blogs/ruby_plot/figures/final_box_plot.png +0 -0
- data/blogs/ruby_plot/figures/final_violin_plot.png +0 -0
- data/blogs/ruby_plot/figures/violin_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot.Rmd +147 -122
- data/blogs/ruby_plot/ruby_plot.Rmd_external_figs +662 -0
- data/blogs/ruby_plot/ruby_plot.html +49 -54
- data/blogs/ruby_plot/ruby_plot.md +147 -122
- data/blogs/ruby_plot/ruby_plot.pdf +0 -0
- data/blogs/ruby_plot/ruby_plot.tex +776 -157
- data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg +57 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg +106 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg +110 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg +174 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg +236 -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.svg +296 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg +236 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg +218 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg +128 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg +150 -0
- data/examples/islr/ch2.spec.rb +21 -18
- data/examples/islr/ch3_boston.rb +14 -5
- data/examples/islr/ch3_multiple_regression.rb +2 -3
- data/examples/islr/ch6.spec.rb +1 -1
- data/examples/islr/x_y_rnorm.jpg +0 -0
- data/lib/R_interface/r.rb +14 -10
- data/lib/R_interface/r_libs.R +9 -0
- data/lib/R_interface/r_methods.rb +77 -6
- data/lib/R_interface/{expression.rb → r_module_s.rb} +13 -14
- data/lib/R_interface/rbinary_operators.rb +58 -71
- data/lib/R_interface/rdata_frame.rb +2 -1
- data/lib/R_interface/rdevices.R +4 -0
- data/lib/R_interface/rdevices.rb +1 -1
- data/lib/R_interface/renvironment.rb +34 -1
- data/lib/R_interface/rexpression.rb +108 -2
- data/lib/R_interface/rindexed_object.rb +3 -1
- data/lib/R_interface/rlanguage.rb +18 -2
- data/lib/R_interface/rmatrix.rb +14 -0
- data/lib/R_interface/rmd_indexed_object.rb +5 -1
- data/lib/R_interface/robject.rb +61 -23
- data/lib/R_interface/rsupport.rb +111 -53
- data/lib/R_interface/rsymbol.rb +6 -5
- data/lib/R_interface/ruby_extensions.rb +130 -4
- data/lib/R_interface/runary_operators.rb +35 -3
- data/lib/R_interface/rvector.rb +1 -0
- data/lib/galaaz.rb +0 -2
- data/lib/gknit/knitr_engine.rb +58 -4
- data/lib/gknit/ruby_engine.rb +5 -6
- data/lib/util/exec_ruby.rb +55 -9
- data/specs/all.rb +13 -3
- data/specs/figures/dose_len.png +0 -0
- data/specs/r_dataframe.spec.rb +49 -26
- data/specs/r_environment.spec.rb +140 -0
- data/specs/r_eval.spec.rb +0 -15
- data/specs/r_formula.spec.rb +232 -0
- data/specs/r_function.spec.rb +7 -8
- data/specs/r_list.spec.rb +4 -0
- data/specs/r_list_apply.spec.rb +11 -11
- data/specs/r_matrix.spec.rb +3 -3
- data/specs/{r_plots.spec.rb~ → r_nse.spec.rb} +29 -6
- data/specs/r_vector_creation.spec.rb +6 -0
- data/specs/r_vector_object.spec.rb +2 -2
- data/specs/r_vector_operators.spec.rb +3 -3
- data/specs/r_vector_subsetting.spec.rb +4 -4
- data/specs/ruby_expression.spec.rb +324 -0
- data/specs/tmp.rb +12 -524
- data/sty/galaaz.sty +71 -0
- data/version.rb +1 -1
- metadata +31 -41
- data/bin/gknit2~ +0 -6
- data/bin/ogk~ +0 -4
- data/bin/prepareR.rb~ +0 -1
- data/blogs/dev/dev.Rmd~ +0 -104
- data/blogs/galaaz_ggplot/galaaz_ggplot.dvi +0 -0
- data/blogs/galaaz_ggplot/midwest_external_png~ +0 -1
- data/blogs/gknit/gknit.Rmd~ +0 -184
- data/blogs/gknit/gknit.Rnd~ +0 -17
- data/blogs/gknit/model.rb~ +0 -46
- data/blogs/ruby_plot/ruby_plot.Rmd~ +0 -215
- data/examples/islr/Figure.jpg +0 -0
- data/examples/misc/moneyball.rb~ +0 -16
- data/examples/misc/subsetting.rb~ +0 -372
- data/lib/R/eng_ruby.R~ +0 -63
- data/lib/R_interface/capture_plot.rb~ +0 -23
- data/lib/R_interface/r.rb~ +0 -121
- data/lib/R_interface/rdevices.rb~ +0 -27
- data/lib/gknit.rb~ +0 -26
- data/lib/gknit/knitr_engine.rb~ +0 -102
- data/lib/gknit/ruby_engine.rb~ +0 -72
- data/lib/util/inline_file.rb~ +0 -23
- data/r_requires/knitr.rb~ +0 -4
- data/specs/r_language.spec.rb +0 -157
data/sty/galaaz.sty
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
% usar portugues do Brasil
|
2
|
+
% \usepackage[brazilian]{babel}
|
3
|
+
\usepackage[utf8]{inputenc}
|
4
|
+
|
5
|
+
\usepackage{geometry}
|
6
|
+
\geometry{a4paper, top=1in}
|
7
|
+
|
8
|
+
% needed for kableExtra
|
9
|
+
\usepackage{longtable}
|
10
|
+
\usepackage{multirow}
|
11
|
+
\usepackage[table]{xcolor}
|
12
|
+
\usepackage{wrapfig}
|
13
|
+
\usepackage{float}
|
14
|
+
\usepackage{colortbl}
|
15
|
+
\usepackage{pdflscape}
|
16
|
+
\usepackage{tabu}
|
17
|
+
\usepackage{threeparttable}
|
18
|
+
\usepackage[normalem]{ulem}
|
19
|
+
|
20
|
+
\usepackage{bbm}
|
21
|
+
\usepackage{booktabs}
|
22
|
+
\usepackage{expex}
|
23
|
+
|
24
|
+
\usepackage{graphicx}
|
25
|
+
|
26
|
+
\usepackage{fancyhdr}
|
27
|
+
% set the header and foot style
|
28
|
+
% style 'fancy' adds the section name on the header
|
29
|
+
% and the page number on the footer
|
30
|
+
\pagestyle{fancy}
|
31
|
+
|
32
|
+
% style 'fancyhf' leaves header and footer empty
|
33
|
+
%\fancyhf{}
|
34
|
+
|
35
|
+
% sets the left head element to \rightmark, which contains the
|
36
|
+
% current section (\leftmark is the current chapter)
|
37
|
+
%\fancyhead[L]{\rightmark} .
|
38
|
+
|
39
|
+
% sets the right head element to the page number.
|
40
|
+
% \fancyhead[R]{\thepage}
|
41
|
+
|
42
|
+
% lets the head rule disappear.
|
43
|
+
% \renewcommand{\headrulewidth}{0pt}
|
44
|
+
% Possible selectors for the optional argument of \fancyhead/\fancyfoot
|
45
|
+
% are L (left), C (center) or R (right) for the position of the element
|
46
|
+
% and E (even) or O (odd) to distinguish even and odd pages. If you omit
|
47
|
+
% E/O the element is set for all pages.
|
48
|
+
|
49
|
+
% \usepackage{lipsum}
|
50
|
+
|
51
|
+
% make available command lastpage
|
52
|
+
\usepackage{lastpage}
|
53
|
+
|
54
|
+
% default fontsize 11pt better to add
|
55
|
+
% fontsize on the yaml header
|
56
|
+
% \usepackage[fontsize=11pt]{scrextend}
|
57
|
+
|
58
|
+
% comandos para formatar uma tabela
|
59
|
+
\usepackage{array}
|
60
|
+
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
|
61
|
+
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
|
62
|
+
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
|
63
|
+
|
64
|
+
% necessário if we need to import other latex documents
|
65
|
+
\usepackage{import}
|
66
|
+
|
67
|
+
% Command to import an R variable to latex
|
68
|
+
\newcommand{\RtoLatex}[2]{\newcommand{#1}{#2}}
|
69
|
+
|
70
|
+
%
|
71
|
+
%\newcommand{\atraso}[1]{\color{red} \textbf {Tempo desde a Assinatura do Contrato: #1 dias}}
|
data/version.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
$gem_name = "galaaz"
|
2
|
-
$version="0.4.
|
2
|
+
$version="0.4.5"
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: galaaz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Botafogo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: pry
|
15
|
-
prerelease: false
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '0.10'
|
21
|
-
type: :runtime
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.10'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rspec
|
29
15
|
prerelease: false
|
@@ -88,27 +74,25 @@ executables:
|
|
88
74
|
extensions: []
|
89
75
|
extra_rdoc_files: []
|
90
76
|
files:
|
77
|
+
- LICENSE
|
91
78
|
- README.md
|
92
79
|
- Rakefile
|
93
80
|
- bin/galaaz
|
94
81
|
- bin/gknit
|
95
82
|
- bin/gknit2
|
96
|
-
- bin/gknit2~
|
97
83
|
- bin/gstudio
|
98
84
|
- bin/gstudio.rb
|
99
|
-
- bin/ogk~
|
100
85
|
- bin/prepareR.rb
|
101
|
-
- bin/prepareR.rb~
|
102
86
|
- bin/tmp.py
|
103
87
|
- blogs/dev/dev.Rmd
|
104
|
-
- blogs/dev/dev.Rmd~
|
105
88
|
- blogs/dev/dev.html
|
106
89
|
- blogs/dev/dev.md
|
107
90
|
- blogs/dev/dev_files/figure-html/bubble-1.png
|
91
|
+
- blogs/dev/dev_files/figure-html/diverging_bar.png
|
108
92
|
- blogs/dev/model.rb
|
93
|
+
- blogs/dplyr/dplyr.rb
|
109
94
|
- blogs/galaaz_ggplot/galaaz_ggplot.Rmd
|
110
95
|
- blogs/galaaz_ggplot/galaaz_ggplot.aux
|
111
|
-
- blogs/galaaz_ggplot/galaaz_ggplot.dvi
|
112
96
|
- blogs/galaaz_ggplot/galaaz_ggplot.html
|
113
97
|
- blogs/galaaz_ggplot/galaaz_ggplot.md
|
114
98
|
- blogs/galaaz_ggplot/galaaz_ggplot.out
|
@@ -118,11 +102,8 @@ files:
|
|
118
102
|
- blogs/galaaz_ggplot/midwest.html
|
119
103
|
- blogs/galaaz_ggplot/midwest.png
|
120
104
|
- blogs/galaaz_ggplot/midwest_external_png
|
121
|
-
- blogs/galaaz_ggplot/midwest_external_png~
|
122
105
|
- blogs/galaaz_ggplot/scatter_plot.png
|
123
106
|
- blogs/gknit/gknit.Rmd
|
124
|
-
- blogs/gknit/gknit.Rmd~
|
125
|
-
- blogs/gknit/gknit.Rnd~
|
126
107
|
- blogs/gknit/gknit.html
|
127
108
|
- blogs/gknit/gknit.md
|
128
109
|
- blogs/gknit/gknit.pdf
|
@@ -130,7 +111,11 @@ files:
|
|
130
111
|
- blogs/gknit/gknit_files/figure-html/bubble-1.png
|
131
112
|
- blogs/gknit/gknit_files/figure-html/diverging_bar.png
|
132
113
|
- blogs/gknit/model.rb
|
133
|
-
- blogs/
|
114
|
+
- blogs/oh_my/not_so.rb
|
115
|
+
- blogs/oh_my/oh_my.Rmd
|
116
|
+
- blogs/oh_my/oh_my.html
|
117
|
+
- blogs/oh_my/oh_my.md
|
118
|
+
- blogs/oh_my/old.Rmd
|
134
119
|
- blogs/ruby_plot/figures/dose_len.png
|
135
120
|
- blogs/ruby_plot/figures/facet_by_delivery.png
|
136
121
|
- blogs/ruby_plot/figures/facet_by_dose.png
|
@@ -143,29 +128,38 @@ files:
|
|
143
128
|
- blogs/ruby_plot/figures/final_violin_plot.png
|
144
129
|
- blogs/ruby_plot/figures/violin_with_jitter.png
|
145
130
|
- blogs/ruby_plot/ruby_plot.Rmd
|
146
|
-
- blogs/ruby_plot/ruby_plot.
|
131
|
+
- blogs/ruby_plot/ruby_plot.Rmd_external_figs
|
147
132
|
- blogs/ruby_plot/ruby_plot.html
|
148
133
|
- blogs/ruby_plot/ruby_plot.md
|
149
134
|
- blogs/ruby_plot/ruby_plot.pdf
|
150
135
|
- blogs/ruby_plot/ruby_plot.tex
|
136
|
+
- blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg
|
137
|
+
- blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg
|
138
|
+
- blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg
|
139
|
+
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg
|
140
|
+
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg
|
141
|
+
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png
|
142
|
+
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.svg
|
143
|
+
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg
|
144
|
+
- blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg
|
145
|
+
- blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg
|
146
|
+
- blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg
|
151
147
|
- examples/50Plots_MasterList/Images/midwest-scatterplot.PNG
|
152
148
|
- examples/50Plots_MasterList/ScatterPlot.rb
|
153
149
|
- examples/50Plots_MasterList/scatter_plot.rb
|
154
150
|
- examples/R/calc.R
|
155
151
|
- examples/R/java_interop.R
|
156
|
-
- examples/islr/Figure.jpg
|
157
152
|
- examples/islr/all.rb
|
158
153
|
- examples/islr/ch2.spec.rb
|
159
154
|
- examples/islr/ch3.spec.rb
|
160
155
|
- examples/islr/ch3_boston.rb
|
161
156
|
- examples/islr/ch3_multiple_regression.rb
|
162
157
|
- examples/islr/ch6.spec.rb
|
158
|
+
- examples/islr/x_y_rnorm.jpg
|
163
159
|
- examples/misc/baseball.csv
|
164
160
|
- examples/misc/ggplot.rb
|
165
161
|
- examples/misc/moneyball.rb
|
166
|
-
- examples/misc/moneyball.rb~
|
167
162
|
- examples/misc/subsetting.rb
|
168
|
-
- examples/misc/subsetting.rb~
|
169
163
|
- examples/paper/paper.rb
|
170
164
|
- examples/sthda_ggplot/README.md
|
171
165
|
- examples/sthda_ggplot/all.rb
|
@@ -197,18 +191,15 @@ files:
|
|
197
191
|
- examples/sthda_ggplot/two_variables_disc_disc/geom_jitter.rb
|
198
192
|
- examples/sthda_ggplot/two_variables_error/geom_crossbar.rb
|
199
193
|
- lib/R/eng_ruby.R
|
200
|
-
- lib/R/eng_ruby.R~
|
201
|
-
- lib/R_interface/capture_plot.rb~
|
202
|
-
- lib/R_interface/expression.rb
|
203
194
|
- lib/R_interface/r.rb
|
204
|
-
- lib/R_interface/
|
195
|
+
- lib/R_interface/r_libs.R
|
205
196
|
- lib/R_interface/r_methods.rb
|
197
|
+
- lib/R_interface/r_module_s.rb
|
206
198
|
- lib/R_interface/rbinary_operators.rb
|
207
199
|
- lib/R_interface/rclosure.rb
|
208
200
|
- lib/R_interface/rdata_frame.rb
|
209
201
|
- lib/R_interface/rdevices.R
|
210
202
|
- lib/R_interface/rdevices.rb
|
211
|
-
- lib/R_interface/rdevices.rb~
|
212
203
|
- lib/R_interface/renvironment.rb
|
213
204
|
- lib/R_interface/rexpression.rb
|
214
205
|
- lib/R_interface/rindexed_object.rb
|
@@ -227,33 +218,32 @@ files:
|
|
227
218
|
- lib/R_interface/rvector.rb
|
228
219
|
- lib/galaaz.rb
|
229
220
|
- lib/gknit.rb
|
230
|
-
- lib/gknit.rb~
|
231
221
|
- lib/gknit/knitr_engine.rb
|
232
|
-
- lib/gknit/knitr_engine.rb~
|
233
222
|
- lib/gknit/ruby_engine.rb
|
234
|
-
- lib/gknit/ruby_engine.rb~
|
235
223
|
- lib/util/exec_ruby.rb
|
236
224
|
- lib/util/inline_file.rb
|
237
|
-
- lib/util/inline_file.rb~
|
238
225
|
- r_requires/ggplot.rb
|
239
226
|
- r_requires/knitr.rb
|
240
|
-
- r_requires/knitr.rb~
|
241
227
|
- specs/all.rb
|
228
|
+
- specs/figures/dose_len.png
|
242
229
|
- specs/r_dataframe.spec.rb
|
230
|
+
- specs/r_environment.spec.rb
|
243
231
|
- specs/r_eval.spec.rb
|
232
|
+
- specs/r_formula.spec.rb
|
244
233
|
- specs/r_function.spec.rb
|
245
|
-
- specs/r_language.spec.rb
|
246
234
|
- specs/r_list.spec.rb
|
247
235
|
- specs/r_list_apply.spec.rb
|
248
236
|
- specs/r_matrix.spec.rb
|
237
|
+
- specs/r_nse.spec.rb
|
249
238
|
- specs/r_plots.spec.rb
|
250
|
-
- specs/r_plots.spec.rb~
|
251
239
|
- specs/r_vector_creation.spec.rb
|
252
240
|
- specs/r_vector_functions.spec.rb
|
253
241
|
- specs/r_vector_object.spec.rb
|
254
242
|
- specs/r_vector_operators.spec.rb
|
255
243
|
- specs/r_vector_subsetting.spec.rb
|
244
|
+
- specs/ruby_expression.spec.rb
|
256
245
|
- specs/tmp.rb
|
246
|
+
- sty/galaaz.sty
|
257
247
|
- version.rb
|
258
248
|
homepage: http://github.com/rbotafogo/galaaz/wiki
|
259
249
|
licenses:
|
data/bin/gknit2~
DELETED
data/bin/ogk~
DELETED
data/bin/prepareR.rb~
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
R.install_and_loads('knitr')
|
data/blogs/dev/dev.Rmd~
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: "gKnit - Ruby and R Knitting with Galaaz in GraalVM"
|
3
|
-
author: "Rodrigo Botafogo"
|
4
|
-
tags: [Galaaz, Ruby, R, TruffleRuby, FastR, GraalVM, knitr]
|
5
|
-
date: "19 October 2018"
|
6
|
-
output:
|
7
|
-
html_document:
|
8
|
-
self_contained: true
|
9
|
-
keep_md: true
|
10
|
-
pdf_document:
|
11
|
-
includes:
|
12
|
-
in_header: ["../../sty/galaaz.sty"]
|
13
|
-
number_sections: yes
|
14
|
-
---
|
15
|
-
|
16
|
-
```{r setup, echo=FALSE}
|
17
|
-
|
18
|
-
```
|
19
|
-
|
20
|
-
# Introduction
|
21
|
-
|
22
|
-
|
23
|
-
```{r bubble}
|
24
|
-
# load package and data
|
25
|
-
library(ggplot2)
|
26
|
-
data(mpg, package="ggplot2")
|
27
|
-
# mpg <- read.csv("http://goo.gl/uEeRGu")
|
28
|
-
|
29
|
-
mpg_select <- mpg[mpg$manufacturer %in% c("audi", "ford", "honda", "hyundai"), ]
|
30
|
-
|
31
|
-
# Scatterplot
|
32
|
-
theme_set(theme_bw()) # pre-set the bw theme.
|
33
|
-
g <- ggplot(mpg_select, aes(displ, cty)) +
|
34
|
-
labs(subtitle="mpg: Displacement vs City Mileage",
|
35
|
-
title="Bubble chart")
|
36
|
-
|
37
|
-
g + geom_jitter(aes(col=manufacturer, size=hwy)) +
|
38
|
-
geom_smooth(aes(col=manufacturer), method="lm", se=F)
|
39
|
-
```
|
40
|
-
|
41
|
-
### Plotting
|
42
|
-
|
43
|
-
```{ruby diverging_bar}
|
44
|
-
require 'ggplot'
|
45
|
-
|
46
|
-
R.theme_set R.theme_bw
|
47
|
-
|
48
|
-
# Data Prep
|
49
|
-
mtcars = ~:mtcars
|
50
|
-
mtcars.car_name = R.rownames(:mtcars)
|
51
|
-
# compute normalized mpg
|
52
|
-
mtcars.mpg_z = ((mtcars.mpg - mtcars.mpg.mean)/mtcars.mpg.sd).round 2
|
53
|
-
mtcars.mpg_type = mtcars.mpg_z < 0 ? "below" : "above"
|
54
|
-
mtcars = mtcars[mtcars.mpg_z.order, :all]
|
55
|
-
# convert to factor to retain sorted order in plot
|
56
|
-
mtcars.car_name = mtcars.car_name.factor levels: mtcars.car_name
|
57
|
-
|
58
|
-
# Diverging Barcharts
|
59
|
-
gg = mtcars.ggplot(E.aes(x: :car_name, y: :mpg_z, label: :mpg_z)) +
|
60
|
-
R.geom_bar(E.aes(fill: :mpg_type), stat: 'identity', width: 0.5) +
|
61
|
-
R.scale_fill_manual(name: "Mileage",
|
62
|
-
labels: R.c("Above Average", "Below Average"),
|
63
|
-
values: R.c("above": "#00ba38", "below": "#f8766d")) +
|
64
|
-
R.labs(subtitle: "Normalised mileage from 'mtcars'",
|
65
|
-
title: "Diverging Bars") +
|
66
|
-
R.coord_flip()
|
67
|
-
|
68
|
-
print gg
|
69
|
-
```
|
70
|
-
|
71
|
-
### Plotting with keep value
|
72
|
-
|
73
|
-
```{ruby diverging_bar2, fig.keep = 1, fig.showtext = TRUE}
|
74
|
-
require 'ggplot'
|
75
|
-
|
76
|
-
R.theme_set R.theme_bw
|
77
|
-
|
78
|
-
# Data Prep
|
79
|
-
mtcars = ~:mtcars
|
80
|
-
mtcars.car_name = R.rownames(:mtcars)
|
81
|
-
# compute normalized mpg
|
82
|
-
mtcars.mpg_z = ((mtcars.mpg - mtcars.mpg.mean)/mtcars.mpg.sd).round 2
|
83
|
-
mtcars.mpg_type = mtcars.mpg_z < 0 ? "below" : "above"
|
84
|
-
mtcars = mtcars[mtcars.mpg_z.order, :all]
|
85
|
-
# convert to factor to retain sorted order in plot
|
86
|
-
mtcars.car_name = mtcars.car_name.factor levels: mtcars.car_name
|
87
|
-
|
88
|
-
# Diverging Barcharts
|
89
|
-
# R.png
|
90
|
-
gg = mtcars.ggplot(E.aes(x: :car_name, y: :mpg_z, label: :mpg_z)) +
|
91
|
-
R.geom_bar(E.aes(fill: :mpg_type), stat: 'identity', width: 0.5) +
|
92
|
-
R.scale_fill_manual(name: "Mileage",
|
93
|
-
labels: R.c("Above Average", "Below Average"),
|
94
|
-
values: R.c("above": "#00ba38", "below": "#f8766d")) +
|
95
|
-
R.labs(subtitle: "Normalised mileage from 'mtcars'",
|
96
|
-
title: "Diverging Bars") +
|
97
|
-
R.coord_flip()
|
98
|
-
|
99
|
-
# print gg
|
100
|
-
|
101
|
-
|
102
|
-
# R.dev__off
|
103
|
-
# R.include_graphics("Rplot001.png")
|
104
|
-
```
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
![Midwest Plot with 'glm' function and modified theme](https://user-images.githubusercontent.com/3999729/47120345-a903ae80-d244-11e8-9be3-a0db13cf51ab.PNG)
|
data/blogs/gknit/gknit.Rmd~
DELETED
@@ -1,184 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: "gKnit - Ruby and R Knitting with Galaaz"
|
3
|
-
author: "Rodrigo Botafogo"
|
4
|
-
tags: [Galaaz, Ruby, R, TruffleRuby, FastR, GraalVM, knitr]
|
5
|
-
date: "19 October 2018"
|
6
|
-
output:
|
7
|
-
html_document:
|
8
|
-
keep_md: true
|
9
|
-
---
|
10
|
-
|
11
|
-
```{r setup, echo=FALSE}
|
12
|
-
|
13
|
-
```
|
14
|
-
|
15
|
-
# Introduction
|
16
|
-
|
17
|
-
The idea of "literate programming" was first introduced by Donald Knuth in the 1980's.
|
18
|
-
The main intention of this approach was to develop code and at the same time document it
|
19
|
-
is as understandably as possible to humans. According to Knuth "The practitioner of
|
20
|
-
literate programming can be regarded as an essayist, whose main concern is with exposition
|
21
|
-
and excellence of style."
|
22
|
-
|
23
|
-
The idea of literate programming envolved into the idea of reproducible research, in which
|
24
|
-
all the data, information and documentation needed to reproduce a research is included in a
|
25
|
-
single document that can be distributed to peers that can rerun the research obtaining
|
26
|
-
the same results.
|
27
|
-
|
28
|
-
The R community has put a great deal of effort in reproducible research. In 2002, Sweave was
|
29
|
-
introduced and it allowed mixing R code with Latex generating hight quality PDF documents. Those
|
30
|
-
documents could include the code, the result of executing the code, graphics and text. This
|
31
|
-
contained the whole narrative to reproduce the research. But Sweave had many problems and in
|
32
|
-
2012, Knitr, developed by Yihui Xie from RStudio was released, solving many of the long lasting
|
33
|
-
problems from Sweave and including in one single package many extensions and add-on packages that
|
34
|
-
were necessary for Sweave. With Knitr, R markdown was also developed, an extension the the
|
35
|
-
Markdown format. With R markdown and Knitr it is possible to generate reports in a multitude
|
36
|
-
of formats such as HTML, markdown, Latex, PDF, dvi, etc. R markdown also allows the use of
|
37
|
-
multiple programming languages in the same document. However, other than R and Python (with
|
38
|
-
the reticulate package), each chunk of code in any other language will execute in a new
|
39
|
-
process, so memory and variables cannot be shared between chunks.
|
40
|
-
|
41
|
-
In the Python community, the same effort to have code and text in an integrated environment
|
42
|
-
started also on the first decade of 2000 and in 2006 iPython 0.7.2 was released. In 2014,
|
43
|
-
Fernando Pérez, spun off project Jupyter from iPython creating a web-based interactive
|
44
|
-
computation environment. Jupyter can now be used with many languages, including Ruby with the
|
45
|
-
iruby gem (https://github.com/SciRuby/iruby). I am not sure if multiple languages can be used
|
46
|
-
in a Jupyter notebook.
|
47
|
-
|
48
|
-
# gKnitting a Document
|
49
|
-
|
50
|
-
This document describes gKnit. gKnit used Knitr and R markdown to knit a document in any of the
|
51
|
-
available formats for R markdown. The only difference between gKnit and normal Knitr documents
|
52
|
-
is that gKnit runs atop of GraalVM, and Galaaz (an integration library between Ruby and R).
|
53
|
-
Another blog post on Galaaz and its integration with ggplot2 can be found at: https://towardsdatascience.com/ruby-plotting-with-galaaz-an-example-of-tightly-coupling-ruby-and-r-in-graalvm-520b69e21021. With
|
54
|
-
Galaaz gKnit can knit documents in Ruby and R and both Ruby and R execute on the same process
|
55
|
-
sharing variables and memory and variables, classes, etc. will be preserved between chunks of
|
56
|
-
code.
|
57
|
-
|
58
|
-
This is not a blog post on rmarkdown, and the intereste user is directed to https://bookdown.org/yihui/rmarkdown/ for detailed information on its capabilities and use. Some of the features available for R code
|
59
|
-
chunks are not yet available for Ruby code. But we are working for removing any limitations.
|
60
|
-
Here, we will describe quickly the main aspects of R markdown, so the user can start gKnit simple
|
61
|
-
documents quickly.
|
62
|
-
|
63
|
-
## The Yaml header
|
64
|
-
|
65
|
-
An R markdown document should start with a Yaml header. This document has the following header that
|
66
|
-
when gKitted will generate and HTML document.
|
67
|
-
|
68
|
-
```
|
69
|
-
---
|
70
|
-
title: "gKnit - Ruby and R Knitting with Galaaz"
|
71
|
-
author: "Rodrigo Botafogo"
|
72
|
-
tags: [Galaaz, Ruby, R, TruffleRuby, FastR, GraalVM, knitr]
|
73
|
-
date: "19 October 2018"
|
74
|
-
output:
|
75
|
-
html_document:
|
76
|
-
keep_md: true
|
77
|
-
---
|
78
|
-
```
|
79
|
-
|
80
|
-
For more information on the options in the Yaml header, check https://bookdown.org/yihui/rmarkdown/html-document.html.
|
81
|
-
|
82
|
-
## R Markdown formatting
|
83
|
-
|
84
|
-
Document formating can be done with simple markups such as:
|
85
|
-
|
86
|
-
### Headers
|
87
|
-
|
88
|
-
```
|
89
|
-
# Header 1
|
90
|
-
|
91
|
-
## Header 2
|
92
|
-
|
93
|
-
### Header 3
|
94
|
-
|
95
|
-
```
|
96
|
-
|
97
|
-
### Lists
|
98
|
-
|
99
|
-
```
|
100
|
-
Unordered lists:
|
101
|
-
|
102
|
-
* Item 1
|
103
|
-
* Item 2
|
104
|
-
+ Item 2a
|
105
|
-
+ Item 2b
|
106
|
-
```
|
107
|
-
|
108
|
-
```
|
109
|
-
Ordered Lists
|
110
|
-
|
111
|
-
1. Item 1
|
112
|
-
2. Item 2
|
113
|
-
3. Item 3
|
114
|
-
+ Item 3a
|
115
|
-
+ Item 3b
|
116
|
-
|
117
|
-
|
118
|
-
```
|
119
|
-
|
120
|
-
Please, go to https://rmarkdown.rstudio.com/authoring_basics.html, for more R markdown formating.
|
121
|
-
|
122
|
-
## Code Chunks
|
123
|
-
|
124
|
-
### R chunks
|
125
|
-
|
126
|
-
Running and executing Ruby and R code is actually what really interests us is this blog. Doing so
|
127
|
-
is very simple with code chunks.
|
128
|
-
|
129
|
-
In order to add R code to a text, a code chunk is added with the following markup:
|
130
|
-
|
131
|
-
So, for instance, here we create an R code chunk setting a variable to a vector:
|
132
|
-
|
133
|
-
<code>```{r var_setting}
|
134
|
-
|
135
|
-
r_vec <- c(1, 2, 3)
|
136
|
-
|
137
|
-
</code>
|
138
|
-
|
139
|
-
<code>```</code>
|
140
|
-
|
141
|
-
```{r var_setting}
|
142
|
-
r_vec <- c(1, 2, 3)
|
143
|
-
```
|
144
|
-
|
145
|
-
|
146
|
-
### Galaaz chunks
|
147
|
-
|
148
|
-
```{galaaz split_data}
|
149
|
-
|
150
|
-
$a = [1, 2, 3]
|
151
|
-
```
|
152
|
-
|
153
|
-
|
154
|
-
```{galaaz split2}
|
155
|
-
|
156
|
-
puts $a
|
157
|
-
|
158
|
-
```
|
159
|
-
|
160
|
-
# Installing gKnit
|
161
|
-
|
162
|
-
## Prerequisites
|
163
|
-
|
164
|
-
* GraalVM (>= rc7)
|
165
|
-
* TruffleRuby
|
166
|
-
* FastR
|
167
|
-
|
168
|
-
The following R packages will be automatically installed when necessary, but could be installed prior
|
169
|
-
to using gKnit if desired:
|
170
|
-
|
171
|
-
* ggplot2
|
172
|
-
* gridExtra
|
173
|
-
* knitr
|
174
|
-
|
175
|
-
Installation of R packages requires a development environment and can be time consuming. In Linux,
|
176
|
-
the gnu compiler and tools should be enough. I am not sure what is needed on the Mac.
|
177
|
-
|
178
|
-
## Preparation
|
179
|
-
|
180
|
-
* gem install galaaz
|
181
|
-
|
182
|
-
## Usage
|
183
|
-
|
184
|
-
* gknit [filename]
|