galaaz 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +696 -270
- data/Rakefile +9 -22
- data/bin/gknit +2 -217
- data/bin/gknit_old_r +236 -0
- data/bin/grun +5 -0
- data/blogs/dev/dev.Rmd +7 -0
- data/blogs/dev/dev.html +34 -26
- data/blogs/dev/dev.md +40 -25
- data/blogs/dev/dev_files/figure-html/bubble-1.png +0 -0
- data/blogs/dev/dev_files/figure-html/diverging_bar. +0 -0
- data/blogs/dev/dev_files/figure-html/diverging_bar.png +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +4 -4
- data/blogs/galaaz_ggplot/galaaz_ggplot.html +251 -59
- data/blogs/galaaz_ggplot/galaaz_ggplot.log +640 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.md +199 -95
- data/blogs/galaaz_ggplot/galaaz_ggplot.tex +45 -228
- data/blogs/galaaz_ggplot/midwest.png +0 -0
- data/blogs/galaaz_ggplot/scatter_plot.png +0 -0
- data/blogs/gknit/gknit.Rmd +271 -148
- data/blogs/manual/manual.Rmd +212 -0
- data/blogs/manual/manual.html +1832 -0
- data/blogs/manual/manual.md +751 -0
- data/blogs/manual/manual_files/figure-html/diverging_bar.png +0 -0
- data/blogs/ruby_plot/ruby_plot.Rmd +5 -69
- data/blogs/ruby_plot/ruby_plot.html +195 -236
- data/blogs/ruby_plot/ruby_plot.md +1 -261
- data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg +38 -38
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_dotplot.rb +5 -5
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_jitter.rb +1 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_violin.rb +3 -7
- data/examples/sthda_ggplot/two_variables_error/geom_crossbar.rb +3 -1
- data/lib/R_interface/r.rb +12 -9
- data/lib/R_interface/r_methods.rb +2 -2
- data/lib/R_interface/rbinary_operators.rb +2 -20
- data/lib/R_interface/rdata_frame.rb +56 -9
- data/lib/R_interface/rdevices.R +0 -12
- data/lib/R_interface/rexpression.rb +0 -97
- data/lib/R_interface/rindexed_object.rb +12 -3
- data/lib/R_interface/rlanguage.rb +1 -1
- data/lib/R_interface/rlist.rb +29 -4
- data/lib/R_interface/rlogical_operators.rb +50 -0
- data/lib/R_interface/rmatrix.rb +7 -1
- data/lib/R_interface/robject.rb +29 -15
- data/lib/R_interface/rsupport.rb +74 -58
- data/lib/R_interface/rsymbol.rb +2 -1
- data/lib/R_interface/ruby_extensions.rb +11 -2
- data/lib/R_interface/rvector.rb +26 -11
- data/lib/gknit.rb +2 -0
- data/lib/gknit/include_engine.rb +57 -0
- data/lib/gknit/knitr_engine.rb +596 -50
- data/lib/gknit/rb_engine.rb +56 -0
- data/lib/gknit/ruby_engine.rb +13 -36
- data/lib/util/exec_ruby.rb +132 -21
- data/lib/util/inline_file.rb +9 -7
- data/specs/all.rb +5 -0
- data/specs/figures/bg.jpeg +0 -0
- data/specs/figures/bg.png +0 -0
- data/specs/figures/bg.svg +57 -0
- data/specs/figures/no_args.jpeg +0 -0
- data/specs/figures/no_args.png +0 -0
- data/specs/figures/no_args.svg +57 -0
- data/specs/figures/width_height.jpeg +0 -0
- data/specs/figures/width_height.png +0 -0
- data/specs/figures/width_height_units1.jpeg +0 -0
- data/specs/figures/width_height_units1.png +0 -0
- data/specs/figures/width_height_units2.jpeg +0 -0
- data/specs/figures/width_height_units2.png +0 -0
- data/specs/r_dataframe.spec.rb +29 -27
- data/specs/r_devices.spec.rb +347 -0
- data/specs/r_eval.spec.rb +10 -3
- data/specs/r_formula.spec.rb +2 -2
- data/specs/r_language.spec.rb +112 -0
- data/specs/r_list.spec.rb +174 -14
- data/specs/r_list_apply.spec.rb +17 -10
- data/specs/r_matrix.spec.rb +3 -3
- data/specs/r_vector_operators.spec.rb +13 -7
- data/specs/tmp.rb +42 -12
- data/version.rb +1 -1
- metadata +28 -24
- data/bin/gknit2 +0 -14
- data/bin/prepareR.rb +0 -3
- data/bin/tmp.py +0 -51
- data/blogs/gknit/gknit.html +0 -528
- data/blogs/gknit/gknit.md +0 -628
- data/blogs/gknit/gknit.pdf +0 -0
- data/blogs/gknit/gknit.tex +0 -745
- 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/ruby_plot/figures/dose_len.png +0 -0
- data/blogs/ruby_plot/figures/facet_by_delivery.png +0 -0
- data/blogs/ruby_plot/figures/facet_by_dose.png +0 -0
- data/blogs/ruby_plot/figures/facets_by_delivery_color.png +0 -0
- data/blogs/ruby_plot/figures/facets_by_delivery_color2.png +0 -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/facets_with_points.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/lib/R/eng_ruby.R +0 -62
- data/lib/R_interface/rdevices.rb +0 -225
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/R/eng_ruby.R
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# define the ruby engine for processing Ruby chunks in
|
2
|
-
# rmarkdown
|
3
|
-
eng_ruby = function(options) {
|
4
|
-
block_code = paste(options$code, collapse = "\\n");
|
5
|
-
code = paste0("GalaazUtil.exec_ruby(",
|
6
|
-
sQuote(block_code),
|
7
|
-
")"
|
8
|
-
);
|
9
|
-
|
10
|
-
keep = options$fig.keep
|
11
|
-
keep.idx = NULL
|
12
|
-
if (is.numeric(keep)) {
|
13
|
-
keep.idx = keep
|
14
|
-
keep = "index"
|
15
|
-
}
|
16
|
-
|
17
|
-
tmp.fig = tempfile(); on.exit(unlink(tmp.fig), add = TRUE)
|
18
|
-
|
19
|
-
# open a device to record plots
|
20
|
-
if (knitr:::chunk_device(options$fig.width[1L], options$fig.height[1L], keep != "none",
|
21
|
-
options$dev, options$dev.args, options$dpi, options, tmp.fig)) {
|
22
|
-
# preserve par() settings from the last code chunk
|
23
|
-
if (keep.pars <- opts_knit$get("global.par"))
|
24
|
-
par2(opts_knit$get("global.pars"))
|
25
|
-
knitr:::showtext(options$fig.showtext) # showtext support
|
26
|
-
dv = dev.cur()
|
27
|
-
on.exit({
|
28
|
-
if (keep.pars) opts_knit$set(global.pars = par(no.readonly = TRUE))
|
29
|
-
dev.off(dv)
|
30
|
-
}, add = TRUE)
|
31
|
-
}
|
32
|
-
|
33
|
-
# guess plot file type if it is NULL
|
34
|
-
if (keep != "none" && is.null(options$fig.ext))
|
35
|
-
options$fig.ext = knitr:::dev2ext(options$dev)
|
36
|
-
|
37
|
-
res = eval.polyglot("ruby", code)
|
38
|
-
|
39
|
-
# rearrange locations of figures
|
40
|
-
figs = find_recordedplot(res)
|
41
|
-
if (length(figs) && any(figs)) {
|
42
|
-
if (keep == 'none') {
|
43
|
-
res = res[!figs] # remove all
|
44
|
-
} else {
|
45
|
-
if (options$fig.show == 'hold') res = c(res[!figs], res[figs]) # move to the end
|
46
|
-
figs = find_recordedplot(res)
|
47
|
-
if (length(figs) && sum(figs) > 1) {
|
48
|
-
if (keep %in% c('first', 'last')) {
|
49
|
-
res = res[-(if (keep == 'last') head else tail)(which(figs), -1L)]
|
50
|
-
} else {
|
51
|
-
# keep only selected
|
52
|
-
if (keep == 'index') res = res[which(figs)[keep.idx]]
|
53
|
-
# merge low-level plotting changes
|
54
|
-
if (keep == 'high') res = merge_low_plot(res, figs)
|
55
|
-
}
|
56
|
-
}
|
57
|
-
}
|
58
|
-
}
|
59
|
-
engine_output(options, block_code, res)
|
60
|
-
}
|
61
|
-
|
62
|
-
knit_engines$set(ruby = eng_ruby)
|
data/lib/R_interface/rdevices.rb
DELETED
@@ -1,225 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
##########################################################################################
|
4
|
-
# @author Rodrigo Botafogo
|
5
|
-
#
|
6
|
-
# Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
|
7
|
-
# and distribute this software and its documentation, without fee and without a signed
|
8
|
-
# licensing agreement, is hereby granted, provided that the above copyright notice, this
|
9
|
-
# paragraph and the following two paragraphs appear in all copies, modifications, and
|
10
|
-
# distributions.
|
11
|
-
#
|
12
|
-
# IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
|
13
|
-
# INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
|
14
|
-
# THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
|
15
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
16
|
-
#
|
17
|
-
# RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
18
|
-
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
|
19
|
-
# SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
|
20
|
-
# RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
|
21
|
-
# OR MODIFICATIONS.
|
22
|
-
##########################################################################################
|
23
|
-
|
24
|
-
require 'singleton'
|
25
|
-
|
26
|
-
dir = File.dirname(File.expand_path('.', __FILE__))
|
27
|
-
src = "#{dir}/rdevices.R"
|
28
|
-
|
29
|
-
R.source(src)
|
30
|
-
|
31
|
-
module R
|
32
|
-
|
33
|
-
class Device
|
34
|
-
|
35
|
-
attr_reader :dev_type, :filename, :width, :height, :dpi, :record,
|
36
|
-
:args, :options, :tmp_file,
|
37
|
-
:dev_number
|
38
|
-
attr_accessor :file_dir
|
39
|
-
|
40
|
-
|
41
|
-
#--------------------------------------------------------------------------------------
|
42
|
-
#
|
43
|
-
#--------------------------------------------------------------------------------------
|
44
|
-
|
45
|
-
def self.list
|
46
|
-
R.dev__list
|
47
|
-
end
|
48
|
-
|
49
|
-
#--------------------------------------------------------------------------------------
|
50
|
-
#
|
51
|
-
#--------------------------------------------------------------------------------------
|
52
|
-
|
53
|
-
def initialize(dev_type, filename: nil, file_dir: '.', width: nil, height: nil,
|
54
|
-
dpi: nil, record: false, args: nil, options: nil, tmp_file: nil)
|
55
|
-
|
56
|
-
@dev_type = dev_type
|
57
|
-
@filename = filename
|
58
|
-
@width = width
|
59
|
-
@height = height
|
60
|
-
@dpi = dpi
|
61
|
-
# TODO: Needs to allow false, but truffle is crashing when false. When it is
|
62
|
-
# fixed, just change to @record = record
|
63
|
-
@record = true
|
64
|
-
|
65
|
-
@args = args
|
66
|
-
@options = options
|
67
|
-
@tmp_file = tmp_file
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
#--------------------------------------------------------------------------------------
|
72
|
-
#
|
73
|
-
#--------------------------------------------------------------------------------------
|
74
|
-
|
75
|
-
def open
|
76
|
-
|
77
|
-
case @dev_type
|
78
|
-
|
79
|
-
when 'svg'
|
80
|
-
when 'awt'
|
81
|
-
R.awt(width: @width, height: @height)
|
82
|
-
@record ? R.dev__control(displaylist: 'enable') :
|
83
|
-
R.dev__control(displaylist: 'inhibit')
|
84
|
-
@dev_number = R.dev__cur
|
85
|
-
when 'png'
|
86
|
-
R.png(filename: @filename, width: @width, height: @height, units: 'in', res: dpi)
|
87
|
-
when 'jpg'
|
88
|
-
when 'bmp'
|
89
|
-
else
|
90
|
-
raise "Device type #{@dev_type} not allowed"
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
#--------------------------------------------------------------------------------------
|
96
|
-
# Opens the device, evaluates the given graphics block expressions and closes the
|
97
|
-
# device at the end of execution
|
98
|
-
#--------------------------------------------------------------------------------------
|
99
|
-
|
100
|
-
def eval(&block)
|
101
|
-
|
102
|
-
if block_given?
|
103
|
-
begin
|
104
|
-
open
|
105
|
-
yield
|
106
|
-
ensure
|
107
|
-
close
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
#--------------------------------------------------------------------------------------
|
114
|
-
# copies the temporary file to the definitive location
|
115
|
-
#--------------------------------------------------------------------------------------
|
116
|
-
|
117
|
-
def copy
|
118
|
-
file = "#{@file_dir}/#{@file_name}.#{ext}"
|
119
|
-
puts file
|
120
|
-
FileUtils.cp(@tmp_file << 0, file)
|
121
|
-
end
|
122
|
-
|
123
|
-
#--------------------------------------------------------------------------------------
|
124
|
-
#
|
125
|
-
#--------------------------------------------------------------------------------------
|
126
|
-
|
127
|
-
def close
|
128
|
-
R.dev__off(which: @dev_number)
|
129
|
-
# copy if @record
|
130
|
-
end
|
131
|
-
|
132
|
-
#--------------------------------------------------------------------------------------
|
133
|
-
#
|
134
|
-
#--------------------------------------------------------------------------------------
|
135
|
-
|
136
|
-
def newpage
|
137
|
-
R.grid__newpage
|
138
|
-
end
|
139
|
-
|
140
|
-
#--------------------------------------------------------------------------------------
|
141
|
-
#
|
142
|
-
#--------------------------------------------------------------------------------------
|
143
|
-
|
144
|
-
def plot_snapshot
|
145
|
-
R.knitr_plot_snapshot
|
146
|
-
end
|
147
|
-
|
148
|
-
#--------------------------------------------------------------------------------------
|
149
|
-
#
|
150
|
-
#--------------------------------------------------------------------------------------
|
151
|
-
|
152
|
-
def ext
|
153
|
-
R.knitr_dev2ext(@dev) << 0
|
154
|
-
end
|
155
|
-
|
156
|
-
#--------------------------------------------------------------------------------------
|
157
|
-
#
|
158
|
-
#--------------------------------------------------------------------------------------
|
159
|
-
|
160
|
-
def save_plot(plot, name, dev, width, height, ext, dpi, options = R.list())
|
161
|
-
R.knitr_save_plot(plot, name, dev, width, height, ext, dpi, options)
|
162
|
-
end
|
163
|
-
|
164
|
-
end
|
165
|
-
|
166
|
-
|
167
|
-
#--------------------------------------------------------------------------------------
|
168
|
-
#
|
169
|
-
#--------------------------------------------------------------------------------------
|
170
|
-
|
171
|
-
class Panel < Device
|
172
|
-
include Singleton
|
173
|
-
|
174
|
-
#--------------------------------------------------------------------------------------
|
175
|
-
#
|
176
|
-
#--------------------------------------------------------------------------------------
|
177
|
-
|
178
|
-
def initialize
|
179
|
-
super('awg', width: nil, height: nil, dpi: nil, record: false, args: nil,
|
180
|
-
options: nil)
|
181
|
-
end
|
182
|
-
|
183
|
-
def exec(&block)
|
184
|
-
yield
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
end
|
190
|
-
|
191
|
-
=begin
|
192
|
-
#--------------------------------------------------------------------------------------
|
193
|
-
#
|
194
|
-
#--------------------------------------------------------------------------------------
|
195
|
-
|
196
|
-
def open2
|
197
|
-
|
198
|
-
case @dev
|
199
|
-
when 'svg'
|
200
|
-
R.svg(@tmp_file)
|
201
|
-
when 'awt'
|
202
|
-
@record = false
|
203
|
-
R.awt
|
204
|
-
when 'png'
|
205
|
-
# for 'png' @record needs to be true, otherwise the device is not
|
206
|
-
# opened. Don't know why, yet!
|
207
|
-
@record = true
|
208
|
-
# opens a device for plot recording.
|
209
|
-
if (R._ck_dv(@width, @height, @dev, @args, @dpi, tmp: @tmp_file,
|
210
|
-
record: @record) << 0)
|
211
|
-
@dv = R.dev__cur
|
212
|
-
else
|
213
|
-
raise "Problem opening the device"
|
214
|
-
end
|
215
|
-
else
|
216
|
-
if (R._ck_dv(@width, @height, @dev, @args, @dpi, tmp: @tmp_file,
|
217
|
-
record: @record) << 0)
|
218
|
-
@dv = R.dev__cur
|
219
|
-
else
|
220
|
-
raise "Problem opening the device"
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
end
|
225
|
-
=end
|