galaaz 0.4.10 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2048 -531
- data/Rakefile +3 -2
- data/bin/gknit +152 -6
- data/bin/gknit-draft +105 -0
- data/bin/gknit-draft.rb +28 -0
- data/bin/gknit_Rscript +127 -0
- data/bin/grun +27 -1
- data/bin/gstudio +47 -4
- data/bin/{gstudio.rb → gstudio_irb.rb} +0 -0
- data/bin/gstudio_pry.rb +7 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.html +10 -195
- data/blogs/galaaz_ggplot/galaaz_ggplot.md +404 -0
- 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/gknit/gknit.Rmd +5 -3
- data/blogs/gknit/gknit.pdf +0 -0
- data/blogs/gknit/lst.rds +0 -0
- data/blogs/manual/lst.rds +0 -0
- data/blogs/manual/manual.Rmd +826 -53
- data/blogs/manual/manual.html +2338 -695
- data/blogs/manual/manual.md +2032 -539
- data/blogs/manual/manual.pdf +0 -0
- data/blogs/manual/manual.tex +1804 -594
- data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
- data/blogs/manual/manual_files/figure-html/diverging_bar.png +0 -0
- data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
- data/blogs/manual/manual_files/figure-latex/diverging_bar.pdf +0 -0
- data/blogs/manual/model.rb +41 -0
- data/blogs/nse_dplyr/nse_dplyr.Rmd +226 -73
- data/blogs/nse_dplyr/nse_dplyr.html +254 -336
- data/blogs/nse_dplyr/nse_dplyr.md +353 -158
- data/blogs/oh_my/oh_my.html +274 -386
- data/blogs/oh_my/oh_my.md +208 -205
- data/blogs/ruby_plot/ruby_plot.html +20 -205
- data/blogs/ruby_plot/ruby_plot.md +14 -15
- 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/examples/Bibliography/master.bib +50 -0
- data/examples/Bibliography/stats.bib +72 -0
- data/examples/islr/x_y_rnorm.jpg +0 -0
- data/examples/latex_templates/Test-acm_article/Makefile +16 -0
- data/examples/latex_templates/Test-acm_article/Test-acm_article.Rmd +65 -0
- data/examples/latex_templates/Test-acm_article/acm_proc_article-sp.cls +1670 -0
- data/examples/latex_templates/Test-acm_article/sensys-abstract.cls +703 -0
- data/examples/latex_templates/Test-acm_article/sigproc.bib +59 -0
- data/examples/latex_templates/Test-acs_article/Test-acs_article.Rmd +260 -0
- data/examples/latex_templates/Test-acs_article/Test-acs_article.pdf +0 -0
- data/examples/latex_templates/Test-acs_article/acs-Test-acs_article.bib +11 -0
- data/examples/latex_templates/Test-acs_article/acs-my_output.bib +11 -0
- data/examples/latex_templates/Test-acs_article/acstest.bib +17 -0
- data/examples/latex_templates/Test-aea_article/AEA.cls +1414 -0
- data/{blogs/gknit/marshal.dump → examples/latex_templates/Test-aea_article/BibFile.bib} +0 -0
- data/examples/latex_templates/Test-aea_article/Test-aea_article.Rmd +108 -0
- data/examples/latex_templates/Test-aea_article/Test-aea_article.pdf +0 -0
- data/examples/latex_templates/Test-aea_article/aea.bst +1269 -0
- data/examples/latex_templates/Test-aea_article/multicol.sty +853 -0
- data/examples/latex_templates/Test-aea_article/references.bib +0 -0
- data/examples/latex_templates/Test-aea_article/setspace.sty +546 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.Rmd +256 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.pdf +0 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.pdfsync +3397 -0
- data/examples/latex_templates/Test-amq_article/pics/Figure2.pdf +0 -0
- data/examples/latex_templates/Test-ams_article/Test-ams_article.Rmd +215 -0
- data/examples/latex_templates/Test-ams_article/amstest.bib +436 -0
- data/examples/latex_templates/Test-asa_article/Test-asa_article.Rmd +153 -0
- data/examples/latex_templates/Test-asa_article/Test-asa_article.pdf +0 -0
- data/examples/latex_templates/Test-asa_article/agsm.bst +1353 -0
- data/examples/latex_templates/Test-asa_article/bibliography.bib +233 -0
- data/examples/latex_templates/Test-ieee_article/IEEEtran.bst +2409 -0
- data/examples/latex_templates/Test-ieee_article/IEEEtran.cls +6346 -0
- data/examples/latex_templates/Test-ieee_article/Test-ieee_article.Rmd +175 -0
- data/examples/latex_templates/Test-ieee_article/Test-ieee_article.pdf +0 -0
- data/examples/latex_templates/Test-ieee_article/mybibfile.bib +20 -0
- data/examples/latex_templates/Test-rjournal_article/RJournal.sty +335 -0
- data/examples/latex_templates/Test-rjournal_article/RJreferences.bib +18 -0
- data/examples/latex_templates/Test-rjournal_article/RJwrapper.pdf +0 -0
- data/examples/latex_templates/Test-rjournal_article/Test-rjournal_article.Rmd +52 -0
- data/examples/latex_templates/Test-springer_article/Test-springer_article.Rmd +65 -0
- data/examples/latex_templates/Test-springer_article/Test-springer_article.pdf +0 -0
- data/examples/latex_templates/Test-springer_article/bibliography.bib +26 -0
- data/examples/latex_templates/Test-springer_article/spbasic.bst +1658 -0
- data/examples/latex_templates/Test-springer_article/spmpsci.bst +1512 -0
- data/examples/latex_templates/Test-springer_article/spphys.bst +1443 -0
- data/examples/latex_templates/Test-springer_article/svglov3.clo +113 -0
- data/examples/latex_templates/Test-springer_article/svjour3.cls +1431 -0
- data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.Rmd +73 -0
- data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.Rmd +382 -0
- data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.Rmd +164 -0
- data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.Rmd +92 -0
- data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/attend-grade-relationships.csv +482 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.Rmd +280 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.pdf +0 -0
- data/examples/rmarkdown/svm-xaringan-example/svm-xaringan-example.Rmd +386 -0
- data/lib/R_interface/r.rb +1 -1
- data/lib/R_interface/r_libs.R +1 -1
- data/lib/R_interface/r_methods.rb +10 -0
- data/lib/R_interface/rpkg.rb +1 -0
- data/lib/R_interface/rsupport.rb +4 -6
- data/lib/gknit.rb +2 -0
- data/lib/gknit/draft.rb +105 -0
- data/lib/gknit/knitr_engine.rb +0 -33
- data/lib/util/exec_ruby.rb +1 -27
- data/specs/figures/bg.jpeg +0 -0
- data/specs/figures/bg.png +0 -0
- data/specs/figures/dose_len.png +0 -0
- data/specs/figures/no_args.jpeg +0 -0
- data/specs/figures/no_args.png +0 -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 +11 -11
- data/specs/ruby_expression.spec.rb +1 -0
- data/specs/tmp.rb +41 -20
- data/version.rb +1 -1
- metadata +73 -35
- data/blogs/galaaz_ggplot/galaaz_ggplot.aux +0 -41
- data/blogs/galaaz_ggplot/galaaz_ggplot.out +0 -10
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/midwest_rb.pdf +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/scatter_plot_rb.pdf +0 -0
- data/blogs/gknit/gknit.md +0 -1430
- data/blogs/gknit/gknit.tex +0 -1358
- data/blogs/manual/graph.rb +0 -29
- data/blogs/nse_dplyr/nse_dplyr.tex +0 -1373
- data/blogs/ruby_plot/ruby_plot.Rmd_external_figs +0 -662
- data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg +0 -57
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg +0 -106
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg +0 -110
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg +0 -174
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg +0 -236
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.svg +0 -296
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg +0 -236
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg +0 -218
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg +0 -128
- data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg +0 -150
- 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/examples/paper/paper.rb +0 -36
data/lib/R_interface/r.rb
CHANGED
data/lib/R_interface/r_libs.R
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
list.of.packages <- c('rlang', 'purrr', 'formula.tools', 'lobstr')
|
1
|
+
list.of.packages <- c('rlang', 'purrr', 'formula.tools', 'lobstr', 'rticles')
|
2
2
|
|
3
3
|
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
|
4
4
|
if(length(new.packages)) install.packages(new.packages)
|
@@ -171,6 +171,16 @@ module R
|
|
171
171
|
R
|
172
172
|
end
|
173
173
|
|
174
|
+
#--------------------------------------------------------------------------------------
|
175
|
+
#
|
176
|
+
#--------------------------------------------------------------------------------------
|
177
|
+
|
178
|
+
Polyglot.eval("R", <<-R)
|
179
|
+
plot = function(...) {
|
180
|
+
print("Function 'plot' is not implemented in fastR. Please, use ggplot instead")
|
181
|
+
}
|
182
|
+
R
|
183
|
+
|
174
184
|
end
|
175
185
|
|
176
186
|
end
|
data/lib/R_interface/rpkg.rb
CHANGED
data/lib/R_interface/rsupport.rb
CHANGED
@@ -209,8 +209,6 @@ module R
|
|
209
209
|
|
210
210
|
#----------------------------------------------------------------------------------------
|
211
211
|
# @param function [R function (Interop)] R function to execute
|
212
|
-
# @param internal [Boolean] true if returning to an internal object, i.e., does not
|
213
|
-
# wrap the return object in a Ruby object
|
214
212
|
# @args [Array] Array of arguments for the function
|
215
213
|
#----------------------------------------------------------------------------------------
|
216
214
|
|
@@ -235,7 +233,7 @@ module R
|
|
235
233
|
res = @@exec_from_ruby.call(R::Object.method(:build), function, pl)
|
236
234
|
# R::Object.build(R::Support.eval("do.call").call(function, pl))
|
237
235
|
end
|
238
|
-
|
236
|
+
|
239
237
|
@@exec_counter = @@exec_counter - 1
|
240
238
|
|
241
239
|
# When execution counter back to 0, print the captured output if the length
|
@@ -249,12 +247,12 @@ module R
|
|
249
247
|
end
|
250
248
|
end
|
251
249
|
end
|
252
|
-
|
250
|
+
|
253
251
|
rescue StandardError => e
|
254
252
|
R::Support.stop_capture.call(@@con) if (@@exec_counter == 0)
|
255
253
|
raise e
|
256
254
|
end
|
257
|
-
|
255
|
+
|
258
256
|
res
|
259
257
|
|
260
258
|
end
|
@@ -266,7 +264,7 @@ module R
|
|
266
264
|
|
267
265
|
def self.exec_function_name(function_name, *args)
|
268
266
|
# @TODO: should check all that can go wrong when calling eval(function_name) to
|
269
|
-
# raise the proper exception
|
267
|
+
# raise the proper exception
|
270
268
|
f = R::Support.eval(function_name)
|
271
269
|
R::Support.exec_function(f, *args)
|
272
270
|
end
|
data/lib/gknit.rb
CHANGED
data/lib/gknit/draft.rb
ADDED
@@ -0,0 +1,105 @@
|
|
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
|
+
module GKnit
|
25
|
+
|
26
|
+
#--------------------------------------------------------------------------------------
|
27
|
+
#
|
28
|
+
#--------------------------------------------------------------------------------------
|
29
|
+
|
30
|
+
Polyglot.eval("R", <<-R)
|
31
|
+
ruby_template = function(gem, family, template, type, ...) {
|
32
|
+
print(gem)
|
33
|
+
print(family)
|
34
|
+
print(template)
|
35
|
+
print(type)
|
36
|
+
data_dir = eval.polyglot("ruby", "GKnit")$template_path(gem, family, template)
|
37
|
+
print(data_dir)
|
38
|
+
invoke(type, list(template = "template.tex", pandoc_args = paste0("--data-dir=", data_dir), ...))
|
39
|
+
}
|
40
|
+
R
|
41
|
+
|
42
|
+
#--------------------------------------------------------------------------------------
|
43
|
+
#
|
44
|
+
#--------------------------------------------------------------------------------------
|
45
|
+
|
46
|
+
def self.template_path(gem, family, template)
|
47
|
+
full_filename = Dir.glob("gknit-templates*", base: "#{Gem.default_dir}/gems")
|
48
|
+
template_path = "#{Gem.default_dir}/gems/#{full_filename[0]}/#{family}/#{template}"
|
49
|
+
end
|
50
|
+
|
51
|
+
#--------------------------------------------------------------------------------------
|
52
|
+
#
|
53
|
+
#--------------------------------------------------------------------------------------
|
54
|
+
|
55
|
+
def self.draft(file:, template:, package: nil,
|
56
|
+
create_dir: 'default', is_package: true, edit: true)
|
57
|
+
|
58
|
+
# ignore the file extension if given. It should always be an .Rmd file
|
59
|
+
file_basename = File.basename(file, File.extname(file))
|
60
|
+
file = "#{file_basename}.Rmd"
|
61
|
+
|
62
|
+
# resolve package file
|
63
|
+
# TODO: if package is a rubygem, then look there somehow
|
64
|
+
if (is_package)
|
65
|
+
template_path =
|
66
|
+
R.system__file("rmarkdown", "templates", template, package: package) >> 0
|
67
|
+
raise "The template '#{template}' was not found in the package '#{package}'" if
|
68
|
+
!(R.nzchar(template_path) >> 0)
|
69
|
+
else
|
70
|
+
full_filename = Dir.glob("gknit-templates*", base: "#{Gem.default_dir}/gems")
|
71
|
+
template_path = "#{Gem.default_dir}/gems/#{full_filename[0]}/#{template}"
|
72
|
+
puts template_path
|
73
|
+
# raise "this is not an R package"
|
74
|
+
end
|
75
|
+
|
76
|
+
# read the template.yaml and confirm it has the right fields
|
77
|
+
template_yaml = File.expand_path("template.yaml", template_path)
|
78
|
+
raise "No 'template.yaml' file found for template '#{template}" if
|
79
|
+
!File.file?(template_yaml)
|
80
|
+
|
81
|
+
template_meta = R::Yaml::yaml__load(R.read_utf8(template_yaml))
|
82
|
+
raise "template.yaml must contain 'name' and 'description' fields" if
|
83
|
+
(template_meta.name.is__null || template_meta.description.is__null) >> 0
|
84
|
+
puts "Creating template:"
|
85
|
+
puts "Template name: #{template_meta.name >> 0}"
|
86
|
+
puts "Description: #{template_meta.description >> 0}"
|
87
|
+
|
88
|
+
if (create_dir == 'default')
|
89
|
+
# check if template asks for new directory
|
90
|
+
create_dir = template_meta.create_dir.isTRUE >> 0
|
91
|
+
|
92
|
+
if (create_dir)
|
93
|
+
raise "The directory '#{file_basename}' already exists" if Dir.exist?(file_basename)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
raise "File #{file} already exists" if File.file?("#{file_basename}/#{file}")
|
99
|
+
FileUtils.cp_r("#{template_path}/skeleton", "#{file_basename}")
|
100
|
+
# FileUtils.cp("#{template_path}/resources/template.tex", "#{file_basename}")
|
101
|
+
File.rename("#{file_basename}/skeleton.Rmd", "#{file_basename}/#{file}")
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
data/lib/gknit/knitr_engine.rb
CHANGED
@@ -687,36 +687,3 @@ class KnitrEngine
|
|
687
687
|
end
|
688
688
|
|
689
689
|
end
|
690
|
-
|
691
|
-
=begin
|
692
|
-
module R
|
693
|
-
|
694
|
-
class Object
|
695
|
-
|
696
|
-
#--------------------------------------------------------------------------------------
|
697
|
-
# Redefine to_s in order to capture plots when in knitr
|
698
|
-
#--------------------------------------------------------------------------------------
|
699
|
-
|
700
|
-
def to_s
|
701
|
-
|
702
|
-
STDERR.puts "+++++++++++++++++++++++++++"
|
703
|
-
STDERR.puts "in to_s"
|
704
|
-
STDERR.puts "+++++++++++++++++++++++++++"
|
705
|
-
|
706
|
-
cap = nil
|
707
|
-
cap = R::Support.capture.call(r_interop)
|
708
|
-
str = String.new
|
709
|
-
(0...(cap.size - 1)).each do |i|
|
710
|
-
str << cap[i] << "\n"
|
711
|
-
end
|
712
|
-
str << cap[cap.size - 1] if cap.size >= 1
|
713
|
-
re = RubyEngine.instance
|
714
|
-
re.capture_plot
|
715
|
-
str
|
716
|
-
end
|
717
|
-
|
718
|
-
end
|
719
|
-
|
720
|
-
end
|
721
|
-
|
722
|
-
=end
|
data/lib/util/exec_ruby.rb
CHANGED
@@ -98,7 +98,7 @@ module GalaazUtil
|
|
98
98
|
# Execute the Ruby code in the scope of class RubyChunk. This is done
|
99
99
|
# so that instance variables created in one chunk can be used again on
|
100
100
|
# another chunk
|
101
|
-
#
|
101
|
+
# RChunk.instance_eval(code) if (options[["eval"]] >> 0)
|
102
102
|
eval(code, RCbinding, __FILE__, __LINE__ + 1) if (options[["eval"]] >> 0)
|
103
103
|
|
104
104
|
# add the returned value to the list
|
@@ -137,30 +137,4 @@ module GalaazUtil
|
|
137
137
|
|
138
138
|
end
|
139
139
|
|
140
|
-
#----------------------------------------------------------------------------------------
|
141
|
-
# Used by old gknit. Will eventually be replaced by exe_ruby
|
142
|
-
#----------------------------------------------------------------------------------------
|
143
|
-
|
144
|
-
def self.exec_ruby_tor(code)
|
145
|
-
|
146
|
-
# the output should be a list with the proper structure to pass to
|
147
|
-
# function engine_output.
|
148
|
-
out_list = R.list(R.structure(R.list(src: code), class: 'source'))
|
149
|
-
|
150
|
-
# Set up standard output as a StringIO object.
|
151
|
-
$stdout = StringIO.new
|
152
|
-
RubyChunk.instance_eval(code)
|
153
|
-
|
154
|
-
# this should have captured everything in the evaluation code
|
155
|
-
# it is not working since at least RC10.
|
156
|
-
out = $stdout.string
|
157
|
-
|
158
|
-
out_list = R.c(out_list, out)
|
159
|
-
|
160
|
-
# return $stdout to standard output
|
161
|
-
$stdout = STDOUT
|
162
|
-
R::Support.parse_arg(out_list)
|
163
|
-
|
164
|
-
end
|
165
|
-
|
166
140
|
end
|
data/specs/figures/bg.jpeg
CHANGED
Binary file
|
data/specs/figures/bg.png
CHANGED
Binary file
|
data/specs/figures/dose_len.png
CHANGED
Binary file
|
data/specs/figures/no_args.jpeg
CHANGED
Binary file
|
data/specs/figures/no_args.png
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/specs/r_dataframe.spec.rb
CHANGED
@@ -321,7 +321,7 @@ describe R::DataFrame do
|
|
321
321
|
end
|
322
322
|
|
323
323
|
#----------------------------------------------------------------------------------------
|
324
|
-
context "
|
324
|
+
context "Bootsraping" do
|
325
325
|
|
326
326
|
before(:each) do
|
327
327
|
@df = R.data__frame(x: R.rep((1..3), each: 2), y: (6..1), z: (~:letters)[(1..6)])
|
@@ -331,8 +331,8 @@ describe R::DataFrame do
|
|
331
331
|
it "should do reordering with integer subsetting" do
|
332
332
|
|
333
333
|
table = @df[R.sample(@df.nrow), :all]
|
334
|
-
expect(table.x[3]).to eq
|
335
|
-
expect(table.y[2]).to eq
|
334
|
+
expect(table.x[3]).to eq 1
|
335
|
+
expect(table.y[2]).to eq 6
|
336
336
|
expect(table.z.levels[6]).to eq "f"
|
337
337
|
|
338
338
|
end
|
@@ -340,17 +340,17 @@ describe R::DataFrame do
|
|
340
340
|
it "should select random rows with integer subsetting" do
|
341
341
|
table = @df[R.sample(@df.nrow, 3), :all]
|
342
342
|
|
343
|
-
expect(table.x[3]).to eq
|
344
|
-
expect(table.y[1]).to eq
|
345
|
-
expect(table.z.levels[table.z[2]]).to eq "
|
343
|
+
expect(table.x[3]).to eq 1
|
344
|
+
expect(table.y[1]).to eq 4
|
345
|
+
expect(table.z.levels[table.z[2]]).to eq "a"
|
346
346
|
end
|
347
347
|
|
348
348
|
it "should randomly reorder a dataframe" do
|
349
349
|
df2 = @df[R.sample(@df.nrow), (3..1)]
|
350
350
|
|
351
|
-
expect(df2.z.levels[df2.z[4]]).to eq "
|
352
|
-
expect(df2.y[2]).to eq
|
353
|
-
expect(df2.x[5]).to eq
|
351
|
+
expect(df2.z.levels[df2.z[4]]).to eq "f"
|
352
|
+
expect(df2.y[2]).to eq 6
|
353
|
+
expect(df2.x[5]).to eq 2
|
354
354
|
end
|
355
355
|
|
356
356
|
it "should reorder by a given variable" do
|
@@ -358,8 +358,8 @@ describe R::DataFrame do
|
|
358
358
|
df2 = df2[df2.x.order, :all]
|
359
359
|
|
360
360
|
expect(df2.x[1]).to eq 1
|
361
|
-
expect(df2.y[1]).to eq
|
362
|
-
expect(df2.z.levels[df2.z[1]]).to eq "
|
361
|
+
expect(df2.y[1]).to eq 6
|
362
|
+
expect(df2.z.levels[df2.z[1]]).to eq "a"
|
363
363
|
end
|
364
364
|
|
365
365
|
it "should reorder variables" do
|
@@ -22,6 +22,7 @@
|
|
22
22
|
##########################################################################################
|
23
23
|
|
24
24
|
require 'galaaz'
|
25
|
+
require 'ggplot'
|
25
26
|
|
26
27
|
#========================================================================================
|
27
28
|
# class Expression in the R module extends Ruby's symbols, so that they can be used in
|
data/specs/tmp.rb
CHANGED
@@ -22,35 +22,56 @@
|
|
22
22
|
##########################################################################################
|
23
23
|
|
24
24
|
require 'galaaz'
|
25
|
+
# require 'gknit'
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
eval("a = 10", RCbinding)
|
30
|
-
eval("puts a", RCbinding)
|
31
|
-
|
32
|
-
code = <<-EOC
|
33
|
-
def test
|
34
|
-
puts "hello from test"
|
35
|
-
end
|
36
|
-
EOC
|
37
|
-
|
38
|
-
eval(code, RCbinding)
|
39
|
-
eval("test", RCbinding)
|
27
|
+
describe "error" do
|
28
|
+
# describe R::DataFrame do
|
40
29
|
|
30
|
+
context "Bootsraping" do
|
41
31
|
|
32
|
+
it "should error with R" do
|
33
|
+
vec = R.c(2)
|
34
|
+
puts vec
|
35
|
+
# expect(vec[1]).to eq 2
|
36
|
+
end
|
42
37
|
|
43
38
|
=begin
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
it "should error with Ruby" do
|
40
|
+
expect(1).to eq 2
|
41
|
+
end
|
42
|
+
|
43
|
+
before(:each) do
|
44
|
+
R.len = 10
|
45
|
+
R.sd = 20
|
46
|
+
R.vec = R.c(1, 2, 3, 4)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should inline r objects in 'expressions'" do
|
50
|
+
e1 = :len + :sd + 5 + R.c(1, 2, 3, 4)
|
51
|
+
expect(e1.rclass).to eq "integer"
|
52
|
+
expect(e1.eval).to eq R.c(36, 37, 38, 39)
|
53
|
+
# expect(e1.eval).not_to eq R.c(35, 37, 38, 39)
|
54
|
+
end
|
55
|
+
=end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
47
60
|
|
48
|
-
puts code2
|
49
61
|
|
50
|
-
|
62
|
+
=begin
|
63
|
+
Polyglot.eval("R", <<-R)
|
64
|
+
library(plotly)
|
65
|
+
m <- highlight_key(mpg)
|
66
|
+
p <- ggplot(m, aes(displ, hwy)) + geom_point()
|
67
|
+
gg <- highlight(ggplotly(p), "plotly_selected")
|
68
|
+
crosstalk::bscols(gg, DT::datatable(m))
|
69
|
+
R
|
51
70
|
=end
|
52
71
|
|
53
|
-
|
72
|
+
# GKnit.draft(file: "rmd_test.Rmd", template: 'acm_article'))
|
73
|
+
# GKnit.draft(file: "rmd_test.Rmd", template: 'acm_article2', package: 'rticles')
|
74
|
+
# GKnit.draft(file: "rmd_test", template: 'acm_article', package: 'rticles')
|
54
75
|
|
55
76
|
## Renaming columns
|
56
77
|
|
data/version.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
$gem_name = "galaaz"
|
2
|
-
$version="0.
|
2
|
+
$version="0.5.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: galaaz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
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: 2020-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -72,6 +72,7 @@ executables:
|
|
72
72
|
- gstudio
|
73
73
|
- gknit
|
74
74
|
- grun
|
75
|
+
- gknit-draft
|
75
76
|
extensions: []
|
76
77
|
extra_rdoc_files: []
|
77
78
|
files:
|
@@ -80,88 +81,68 @@ files:
|
|
80
81
|
- Rakefile
|
81
82
|
- bin/galaaz
|
82
83
|
- bin/gknit
|
84
|
+
- bin/gknit-draft
|
85
|
+
- bin/gknit-draft.rb
|
86
|
+
- bin/gknit_Rscript
|
83
87
|
- bin/grun
|
84
88
|
- bin/gstudio
|
85
|
-
- bin/
|
89
|
+
- bin/gstudio_irb.rb
|
90
|
+
- bin/gstudio_pry.rb
|
86
91
|
- blogs/galaaz_ggplot/galaaz_ggplot.Rmd
|
87
|
-
- blogs/galaaz_ggplot/galaaz_ggplot.aux
|
88
92
|
- blogs/galaaz_ggplot/galaaz_ggplot.html
|
89
|
-
- blogs/galaaz_ggplot/galaaz_ggplot.
|
93
|
+
- blogs/galaaz_ggplot/galaaz_ggplot.md
|
90
94
|
- blogs/galaaz_ggplot/galaaz_ggplot.pdf
|
91
95
|
- blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/midwest_rb.png
|
92
96
|
- blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/scatter_plot_rb.png
|
93
|
-
- blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/midwest_rb.pdf
|
94
|
-
- blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/scatter_plot_rb.pdf
|
95
97
|
- blogs/galaaz_ggplot/midwest.Rmd
|
96
98
|
- blogs/galaaz_ggplot/midwest.html
|
97
99
|
- blogs/galaaz_ggplot/midwest_external_png
|
98
100
|
- blogs/gknit/gknit.Rmd
|
99
101
|
- blogs/gknit/gknit.html
|
100
|
-
- blogs/gknit/gknit.md
|
101
102
|
- blogs/gknit/gknit.pdf
|
102
|
-
- blogs/gknit/gknit.tex
|
103
103
|
- blogs/gknit/lst.rds
|
104
|
-
- blogs/gknit/marshal.dump
|
105
104
|
- blogs/gknit/model.rb
|
106
105
|
- blogs/gknit/stats.bib
|
107
|
-
- blogs/manual/
|
106
|
+
- blogs/manual/lst.rds
|
108
107
|
- blogs/manual/manual.Rmd
|
109
108
|
- blogs/manual/manual.html
|
110
109
|
- blogs/manual/manual.md
|
111
110
|
- blogs/manual/manual.pdf
|
112
111
|
- blogs/manual/manual.tex
|
112
|
+
- blogs/manual/manual_files/figure-html/bubble-1.png
|
113
113
|
- blogs/manual/manual_files/figure-html/diverging_bar.png
|
114
|
+
- blogs/manual/manual_files/figure-latex/bubble-1.png
|
114
115
|
- blogs/manual/manual_files/figure-latex/diverging_bar.pdf
|
116
|
+
- blogs/manual/model.rb
|
115
117
|
- blogs/nse_dplyr/nse_dplyr.Rmd
|
116
118
|
- blogs/nse_dplyr/nse_dplyr.html
|
117
119
|
- blogs/nse_dplyr/nse_dplyr.md
|
118
120
|
- blogs/nse_dplyr/nse_dplyr.pdf
|
119
|
-
- blogs/nse_dplyr/nse_dplyr.tex
|
120
121
|
- blogs/oh_my/not_so.rb
|
121
122
|
- blogs/oh_my/oh_my.Rmd
|
122
123
|
- blogs/oh_my/oh_my.html
|
123
124
|
- blogs/oh_my/oh_my.md
|
124
125
|
- blogs/oh_my/old.Rmd
|
125
126
|
- blogs/ruby_plot/ruby_plot.Rmd
|
126
|
-
- blogs/ruby_plot/ruby_plot.Rmd_external_figs
|
127
127
|
- blogs/ruby_plot/ruby_plot.html
|
128
128
|
- blogs/ruby_plot/ruby_plot.md
|
129
129
|
- blogs/ruby_plot/ruby_plot.pdf
|
130
130
|
- blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png
|
131
|
-
- blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg
|
132
131
|
- blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png
|
133
|
-
- blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg
|
134
132
|
- blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png
|
135
|
-
- blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg
|
136
133
|
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png
|
137
|
-
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg
|
138
134
|
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png
|
139
|
-
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg
|
140
135
|
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png
|
141
136
|
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png
|
142
|
-
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.svg
|
143
137
|
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png
|
144
|
-
- blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg
|
145
138
|
- blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png
|
146
|
-
- blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg
|
147
139
|
- blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png
|
148
|
-
- blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg
|
149
140
|
- blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png
|
150
|
-
- blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg
|
151
|
-
- blogs/ruby_plot/ruby_plot_files/figure-latex/dose_len.png
|
152
|
-
- blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_delivery.png
|
153
|
-
- blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_dose.png
|
154
|
-
- blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color.png
|
155
|
-
- blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color2.png
|
156
|
-
- blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_decorations.png
|
157
|
-
- blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_jitter.png
|
158
|
-
- blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_points.png
|
159
|
-
- blogs/ruby_plot/ruby_plot_files/figure-latex/final_box_plot.png
|
160
|
-
- blogs/ruby_plot/ruby_plot_files/figure-latex/final_violin_plot.png
|
161
|
-
- blogs/ruby_plot/ruby_plot_files/figure-latex/violin_with_jitter.png
|
162
141
|
- examples/50Plots_MasterList/Images/midwest-scatterplot.PNG
|
163
142
|
- examples/50Plots_MasterList/ScatterPlot.rb
|
164
143
|
- examples/50Plots_MasterList/scatter_plot.rb
|
144
|
+
- examples/Bibliography/master.bib
|
145
|
+
- examples/Bibliography/stats.bib
|
165
146
|
- examples/R/calc.R
|
166
147
|
- examples/R/java_interop.R
|
167
148
|
- examples/islr/all.rb
|
@@ -171,11 +152,67 @@ files:
|
|
171
152
|
- examples/islr/ch3_multiple_regression.rb
|
172
153
|
- examples/islr/ch6.spec.rb
|
173
154
|
- examples/islr/x_y_rnorm.jpg
|
155
|
+
- examples/latex_templates/Test-acm_article/Makefile
|
156
|
+
- examples/latex_templates/Test-acm_article/Test-acm_article.Rmd
|
157
|
+
- examples/latex_templates/Test-acm_article/acm_proc_article-sp.cls
|
158
|
+
- examples/latex_templates/Test-acm_article/sensys-abstract.cls
|
159
|
+
- examples/latex_templates/Test-acm_article/sigproc.bib
|
160
|
+
- examples/latex_templates/Test-acs_article/Test-acs_article.Rmd
|
161
|
+
- examples/latex_templates/Test-acs_article/Test-acs_article.pdf
|
162
|
+
- examples/latex_templates/Test-acs_article/acs-Test-acs_article.bib
|
163
|
+
- examples/latex_templates/Test-acs_article/acs-my_output.bib
|
164
|
+
- examples/latex_templates/Test-acs_article/acstest.bib
|
165
|
+
- examples/latex_templates/Test-aea_article/AEA.cls
|
166
|
+
- examples/latex_templates/Test-aea_article/BibFile.bib
|
167
|
+
- examples/latex_templates/Test-aea_article/Test-aea_article.Rmd
|
168
|
+
- examples/latex_templates/Test-aea_article/Test-aea_article.pdf
|
169
|
+
- examples/latex_templates/Test-aea_article/aea.bst
|
170
|
+
- examples/latex_templates/Test-aea_article/multicol.sty
|
171
|
+
- examples/latex_templates/Test-aea_article/references.bib
|
172
|
+
- examples/latex_templates/Test-aea_article/setspace.sty
|
173
|
+
- examples/latex_templates/Test-amq_article/Test-amq_article.Rmd
|
174
|
+
- examples/latex_templates/Test-amq_article/Test-amq_article.pdf
|
175
|
+
- examples/latex_templates/Test-amq_article/Test-amq_article.pdfsync
|
176
|
+
- examples/latex_templates/Test-amq_article/pics/Figure2.pdf
|
177
|
+
- examples/latex_templates/Test-ams_article/Test-ams_article.Rmd
|
178
|
+
- examples/latex_templates/Test-ams_article/amstest.bib
|
179
|
+
- examples/latex_templates/Test-asa_article/Test-asa_article.Rmd
|
180
|
+
- examples/latex_templates/Test-asa_article/Test-asa_article.pdf
|
181
|
+
- examples/latex_templates/Test-asa_article/agsm.bst
|
182
|
+
- examples/latex_templates/Test-asa_article/bibliography.bib
|
183
|
+
- examples/latex_templates/Test-ieee_article/IEEEtran.bst
|
184
|
+
- examples/latex_templates/Test-ieee_article/IEEEtran.cls
|
185
|
+
- examples/latex_templates/Test-ieee_article/Test-ieee_article.Rmd
|
186
|
+
- examples/latex_templates/Test-ieee_article/Test-ieee_article.pdf
|
187
|
+
- examples/latex_templates/Test-ieee_article/mybibfile.bib
|
188
|
+
- examples/latex_templates/Test-rjournal_article/RJournal.sty
|
189
|
+
- examples/latex_templates/Test-rjournal_article/RJreferences.bib
|
190
|
+
- examples/latex_templates/Test-rjournal_article/RJwrapper.pdf
|
191
|
+
- examples/latex_templates/Test-rjournal_article/Test-rjournal_article.Rmd
|
192
|
+
- examples/latex_templates/Test-springer_article/Test-springer_article.Rmd
|
193
|
+
- examples/latex_templates/Test-springer_article/Test-springer_article.pdf
|
194
|
+
- examples/latex_templates/Test-springer_article/bibliography.bib
|
195
|
+
- examples/latex_templates/Test-springer_article/spbasic.bst
|
196
|
+
- examples/latex_templates/Test-springer_article/spmpsci.bst
|
197
|
+
- examples/latex_templates/Test-springer_article/spphys.bst
|
198
|
+
- examples/latex_templates/Test-springer_article/svglov3.clo
|
199
|
+
- examples/latex_templates/Test-springer_article/svjour3.cls
|
174
200
|
- examples/misc/baseball.csv
|
175
201
|
- examples/misc/ggplot.rb
|
176
202
|
- examples/misc/moneyball.rb
|
177
203
|
- examples/misc/subsetting.rb
|
178
|
-
- examples/
|
204
|
+
- examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.Rmd
|
205
|
+
- examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.pdf
|
206
|
+
- examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.Rmd
|
207
|
+
- examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.pdf
|
208
|
+
- examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.Rmd
|
209
|
+
- examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.pdf
|
210
|
+
- examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.Rmd
|
211
|
+
- examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.pdf
|
212
|
+
- examples/rmarkdown/svm-rmarkdown-syllabus-example/attend-grade-relationships.csv
|
213
|
+
- examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.Rmd
|
214
|
+
- examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.pdf
|
215
|
+
- examples/rmarkdown/svm-xaringan-example/svm-xaringan-example.Rmd
|
179
216
|
- examples/sthda_ggplot/README.md
|
180
217
|
- examples/sthda_ggplot/all.rb
|
181
218
|
- examples/sthda_ggplot/one_variable_continuous/density_gg.rb
|
@@ -232,6 +269,7 @@ files:
|
|
232
269
|
- lib/R_interface/rvector.rb
|
233
270
|
- lib/galaaz.rb
|
234
271
|
- lib/gknit.rb
|
272
|
+
- lib/gknit/draft.rb
|
235
273
|
- lib/gknit/include_engine.rb
|
236
274
|
- lib/gknit/knitr_engine.rb
|
237
275
|
- lib/gknit/rb_engine.rb
|