galaaz 0.4.0

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 (86) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +32 -0
  3. data/Rakefile +177 -0
  4. data/bin/galaaz +8 -0
  5. data/examples/50Plots_MasterList/scatter_plot.rb +51 -0
  6. data/examples/baseball.csv +1 -0
  7. data/examples/baseball.rb +16 -0
  8. data/examples/ggplot.rb +178 -0
  9. data/examples/islr/Figure.jpg +0 -0
  10. data/examples/islr/all.rb +32 -0
  11. data/examples/islr/ch2.spec.rb +148 -0
  12. data/examples/islr/ch3.spec.rb +28 -0
  13. data/examples/islr/ch3_boston.rb +77 -0
  14. data/examples/islr/ch3_multiple_regression.rb +36 -0
  15. data/examples/islr/ch6.spec.rb +64 -0
  16. data/examples/paper/paper.rb +36 -0
  17. data/examples/sthda_ggplot/README.md +38 -0
  18. data/examples/sthda_ggplot/all.rb +68 -0
  19. data/examples/sthda_ggplot/one_variable_continuous/density_gg.rb +52 -0
  20. data/examples/sthda_ggplot/one_variable_continuous/geom_area.rb +61 -0
  21. data/examples/sthda_ggplot/one_variable_continuous/geom_density.rb +77 -0
  22. data/examples/sthda_ggplot/one_variable_continuous/geom_dotplot.rb +69 -0
  23. data/examples/sthda_ggplot/one_variable_continuous/geom_freqpoly.rb +69 -0
  24. data/examples/sthda_ggplot/one_variable_continuous/geom_histogram.rb +62 -0
  25. data/examples/sthda_ggplot/one_variable_continuous/histogram_density.rb +55 -0
  26. data/examples/sthda_ggplot/one_variable_continuous/stat.rb +62 -0
  27. data/examples/sthda_ggplot/one_variable_discrete/bar.rb +54 -0
  28. data/examples/sthda_ggplot/qplots/box_violin_dot.rb +57 -0
  29. data/examples/sthda_ggplot/qplots/scatter_plots.rb +67 -0
  30. data/examples/sthda_ggplot/scatter_gg.rb +60 -0
  31. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_bin2d.rb +49 -0
  32. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_density2d.rb +64 -0
  33. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_hex.rb +52 -0
  34. data/examples/sthda_ggplot/two_variables_cont_cont/geom_point.rb +65 -0
  35. data/examples/sthda_ggplot/two_variables_cont_cont/geom_smooth.rb +66 -0
  36. data/examples/sthda_ggplot/two_variables_cont_cont/misc.rb +83 -0
  37. data/examples/sthda_ggplot/two_variables_cont_function/geom_area.rb +63 -0
  38. data/examples/sthda_ggplot/two_variables_disc_cont/geom_bar.rb +85 -0
  39. data/examples/sthda_ggplot/two_variables_disc_cont/geom_boxplot.rb +62 -0
  40. data/examples/sthda_ggplot/two_variables_disc_cont/geom_dotplot.rb +75 -0
  41. data/examples/sthda_ggplot/two_variables_disc_cont/geom_jitter.rb +74 -0
  42. data/examples/sthda_ggplot/two_variables_disc_cont/geom_line.rb +55 -0
  43. data/examples/sthda_ggplot/two_variables_disc_cont/geom_violin.rb +70 -0
  44. data/examples/sthda_ggplot/two_variables_disc_disc/geom_jitter.rb +40 -0
  45. data/examples/sthda_ggplot/two_variables_error/geom_crossbar.rb +108 -0
  46. data/examples/subsetting.rb +372 -0
  47. data/lib/expression.rb +45 -0
  48. data/lib/galaaz.rb +27 -0
  49. data/lib/r.rb +118 -0
  50. data/lib/r_methods.rb +89 -0
  51. data/lib/rbinary_operators.rb +226 -0
  52. data/lib/rclosure.rb +34 -0
  53. data/lib/rdata_frame.rb +63 -0
  54. data/lib/renvironment.rb +34 -0
  55. data/lib/rexpression.rb +34 -0
  56. data/lib/rindexed_object.rb +68 -0
  57. data/lib/rlanguage.rb +64 -0
  58. data/lib/rlist.rb +72 -0
  59. data/lib/rmatrix.rb +38 -0
  60. data/lib/rmd_indexed_object.rb +43 -0
  61. data/lib/robject.rb +297 -0
  62. data/lib/rpkg.rb +53 -0
  63. data/lib/rsupport.rb +292 -0
  64. data/lib/rsupport_scope.rb +77 -0
  65. data/lib/rsymbol.rb +57 -0
  66. data/lib/ruby_callback.rb +83 -0
  67. data/lib/ruby_extensions.rb +74 -0
  68. data/lib/runary_operators.rb +58 -0
  69. data/lib/rvector.rb +117 -0
  70. data/r_requires/ggplot.rb +31 -0
  71. data/specs/all.rb +45 -0
  72. data/specs/r_dataframe.spec.rb +181 -0
  73. data/specs/r_eval.spec.rb +164 -0
  74. data/specs/r_function.spec.rb +105 -0
  75. data/specs/r_language.spec.rb +135 -0
  76. data/specs/r_list.spec.rb +129 -0
  77. data/specs/r_list_apply.spec.rb +99 -0
  78. data/specs/r_matrix.spec.rb +83 -0
  79. data/specs/r_vector_creation.spec.rb +99 -0
  80. data/specs/r_vector_functions.spec.rb +59 -0
  81. data/specs/r_vector_object.spec.rb +94 -0
  82. data/specs/r_vector_operators.spec.rb +174 -0
  83. data/specs/r_vector_subsetting.spec.rb +136 -0
  84. data/specs/tmp.rb +134 -0
  85. data/version.rb +2 -0
  86. metadata +198 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 472e7863d96eb66bf0aa0e78194c021c5a128049
4
+ data.tar.gz: b5742fe889c830c83f1c53bd091ffa43d3ec44fb
5
+ SHA512:
6
+ metadata.gz: 0f39228250f568f09d322dc1b70647982cdfa785e895695e30dab20ba595f5a5fe42ec5f56076c3deddbde8a7ff3172a7addc35c913315bb3f2c2d151d998107
7
+ data.tar.gz: 8e407929466a0d8152c0eb8c7ea5b28bea0ed2818c3abcc732659845448c01898dd6af7cf0332233bcc5ce29d9718285a1a747c2f1fc72ea08ad401aa712d1ad
@@ -0,0 +1,32 @@
1
+ # Running Ruby and R - The Polyglot Environment
2
+
3
+ TruffleRuby (the Polyglot implementation of Ruby) can access, through the Polyglot interface, any other
4
+ language available in the environment. For instance, in the code bellow, TruffleRuby makes a call to
5
+ JavaScript:
6
+
7
+ require 'json'
8
+
9
+ obj = {time: Time.now,
10
+ msg: 'Hello World',
11
+ payload: (1..10).to_a }
12
+
13
+ encoded = JSON.dump(obj)
14
+
15
+ js_obj = Polyglot.eval('js', 'JSON.parse').call(encoded)
16
+ puts js_obj[:time]
17
+ puts js_obj[:msg]
18
+ puts js_obj[:payload].join(' ')
19
+
20
+ Calling R is similar to the above. For example, in R, method 'c' concatenates its arguments making a vector:
21
+
22
+ vec = Polyglot.eval('R', 'c').call(1, 2, 3)
23
+ puts vec[0]
24
+ p vec
25
+ > 1
26
+ > #<Truffle::Interop::Foreign@5d03df76>
27
+
28
+ As can be seen, vec is a vector with the first element (indexed at 0 - Ruby indexing) is 1.
29
+ Inspecting vec, show that it is a Truffle::Interop object. Although it is possible to work with
30
+ Interop objects in a program, doing so is hard and error prone. Bellow, we show how integration of
31
+ Ruby and R can greatly simplify the development of Polyglot application.
32
+
@@ -0,0 +1,177 @@
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 'rake/tasklib'
25
+ require 'rake/testtask'
26
+
27
+ require_relative 'version'
28
+
29
+ #----------------------------------------------------------------------------------------
30
+ #
31
+ #----------------------------------------------------------------------------------------
32
+
33
+ class MakeTask < Rake::TaskLib
34
+
35
+ # Create class variables for the polyglot options and libs
36
+ @@polyglot_options = "--polyglot --jvm -Xsingle_threaded"
37
+ @@libs = "-Ilib/" # -Ir_requires/"
38
+
39
+ #----------------------------------------------------------------------------------------
40
+ #
41
+ #----------------------------------------------------------------------------------------
42
+
43
+ def initialize(group, dir_name, task_name, rspec,
44
+ description = "#{group}:#{task_name}")
45
+ @name = "#{group}:#{task_name}"
46
+ @filepath = "#{dir_name}/#{task_name}"
47
+ @group = group
48
+ @description = description
49
+ @rspec = rspec
50
+
51
+ yield self if block_given?
52
+ define
53
+ end
54
+
55
+ #----------------------------------------------------------------------------------------
56
+ # Actual TruffleRuby command (with options) to run the example
57
+ #----------------------------------------------------------------------------------------
58
+
59
+ def make_task
60
+ @rspec ?
61
+ (sh %{ ruby #{@@polyglot_options} #{@@libs} -S rspec #{@filepath}.rb -f documentation }) :
62
+ (sh %{ ruby #{@@polyglot_options} #{@@libs} -S #{@filepath}.rb })
63
+ end
64
+
65
+ #----------------------------------------------------------------------------------------
66
+ # Creates the tasks. It the task is already defined, then append to it (enhance)
67
+ #----------------------------------------------------------------------------------------
68
+
69
+ def define
70
+ desc @description
71
+ Rake::Task.task_defined?(@name) ? Rake::Task[@name].enhance { make_task } :
72
+ (task(@name) { make_task } )
73
+ end
74
+
75
+ end
76
+
77
+ geoms = FileList['examples/sthda_ggplot/**/*.rb']
78
+ specs = FileList['specs/**/*.rb']
79
+ master_list = FileList['examples/50Plots_MasterList/**/*.rb']
80
+ islr = FileList['examples/islr/**/*.rb']
81
+
82
+ #===========================================================================================
83
+ # Creates tasks for all specs.
84
+ # Running 'rake specs:all' will run all specs
85
+ #===========================================================================================
86
+
87
+ specs.each do |f|
88
+ task_name = File.basename(f, ".rb")
89
+ dir_name = File.dirname(f)
90
+ MakeTask.new("specs", dir_name, task_name, true, <<-Desc)
91
+ Executes spec #{task_name}
92
+ Desc
93
+ end
94
+
95
+ #===========================================================================================
96
+ # Creates tasks for ggplot graphics from sthda website
97
+ # Running 'rake sthda:all' will run a slide show of all plots available
98
+ #===========================================================================================
99
+
100
+ geoms.each do |f|
101
+ task_name = File.basename(f, ".rb")
102
+ dir_name = File.dirname(f)
103
+ MakeTask.new("sthda", dir_name, task_name, false, <<-Desc)
104
+ ggplot for #{task_name}
105
+ Desc
106
+ end
107
+
108
+ #===========================================================================================
109
+ # Creates tasks for ggplot graphics from r-statistics.co website
110
+ # Running 'rake master_list:all' will run a slide show of all plots available
111
+ #===========================================================================================
112
+
113
+ master_list.each do |f|
114
+ task_name = File.basename(f, ".rb")
115
+ dir_name = File.dirname(f)
116
+ MakeTask.new("master_list", dir_name, task_name, false, <<-Desc)
117
+ #{task_name} from: http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html
118
+ Desc
119
+ end
120
+
121
+ #===========================================================================================
122
+ # Creates tasks for the Introduction to Statistical Learning book labs
123
+ # Running 'rake islr:all' will run all specs
124
+ #===========================================================================================
125
+
126
+ islr.each do |f|
127
+ task_name = File.basename(f, ".rb")
128
+ dir_name = File.dirname(f)
129
+ MakeTask.new("islr", dir_name, task_name, true, <<-Desc)
130
+ Executes islr #{task_name}
131
+ Desc
132
+ end
133
+
134
+ task :default => "sthda:all"
135
+
136
+
137
+ =begin
138
+ name = "#{$gem_name}-#{$version}.gem"
139
+
140
+ desc 'default task'
141
+ task :default => [:install_gem]
142
+
143
+ desc 'Makes a Gem'
144
+ task :make_gem do
145
+ sh "gem build #{$gem_name}.gemspec"
146
+ end
147
+
148
+ desc 'Install the gem in the standard location'
149
+ task :install_gem => [:make_gem] do
150
+ sh "gem install #{$gem_name}-#{$version}-java.gem"
151
+ end
152
+
153
+ desc 'Make documentation'
154
+ task :make_doc do
155
+ sh "yard doc lib/*.rb lib/**/*.rb"
156
+ end
157
+
158
+ desc 'Push project to github'
159
+ task :push do
160
+ sh "git push origin master"
161
+ end
162
+
163
+ desc 'Push gem to rubygem'
164
+ task :push_gem do
165
+ sh "push #{name} -p $http_proxy"
166
+ end
167
+
168
+ Rake::TestTask.new do |t|
169
+ t.libs << "test"
170
+ t.test_files = FileList['test/complete.rb']
171
+ t.ruby_opts = ["--server", "-Xinvokedynamic.constants=true", "-J-Xmn512m",
172
+ "-J-Xms1024m", "-J-Xmx1024m"]
173
+ t.verbose = true
174
+ t.warning = true
175
+ end
176
+
177
+ =end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Dir.chdir(File.expand_path('..', Dir.pwd))
4
+ Dir.chdir(File.dirname(File.expand_path('..', __FILE__)))
5
+
6
+ puts Dir.pwd
7
+
8
+ system ("rake #{ARGV[0]}")
@@ -0,0 +1,51 @@
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 'galaaz'
25
+ require 'ggplot'
26
+
27
+ # load package and data
28
+ R.options(scipen: 999) # turn-off scientific notation like 1e+48
29
+ R.theme_set(R.theme_bw) # pre-set the bw theme.
30
+
31
+ midwest = ~:midwest
32
+ # midwest <- read.csv("http://goo.gl/G1K41K") # bkup data source
33
+
34
+ R.awt
35
+
36
+ # Scatterplot
37
+ gg = midwest.ggplot(E.aes(x: :area, y: :poptotal)) +
38
+ R.geom_point(E.aes(col: :state, size: :popdensity)) +
39
+ R.geom_smooth(method: "loess", se: false) +
40
+ R.xlim(R.c(0, 0.1)) +
41
+ R.ylim(R.c(0, 500000)) +
42
+ R.labs(subtitle: "Area Vs Population",
43
+ y: "Population",
44
+ x: "Area",
45
+ title: "Scatterplot",
46
+ caption: "Source: midwest")
47
+
48
+ puts gg
49
+
50
+ sleep(2)
51
+ # a = gets.chomp
@@ -0,0 +1 @@
1
+ Team,League,Year,RS,RA,W,OBP,SLG,BA,Playoffs,RankSeason,RankPlayoffs,G,OOBP,OSLG
@@ -0,0 +1,16 @@
1
+ # coding: utf-8
2
+
3
+ require 'galaaz'
4
+
5
+ # This dataset comes from Baseball-Reference.com.
6
+ baseball = R.read__csv("baseball.csv")
7
+ # Lets look at the data available for Momeyball.
8
+ moneyball = baseball.subset(baseball.Year < 2002)
9
+ # Let's see if we can predict the number of wins, by looking at
10
+ # runs allowed (RA) and runs scored (RS). RD is the runs difference.
11
+ # We are making a linear model for predicting wins (W) based on RD
12
+
13
+ moneyball.RD = moneyball.RS - moneyball.RA
14
+ wins_reg = R.lm(+:W =~ +:RD, data: moneyball)
15
+ wins_reg.summary.pp
16
+
@@ -0,0 +1,178 @@
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 'galaaz'
25
+ require 'ggplot'
26
+
27
+ module LightBlueTheme
28
+
29
+ #--------------------------------------------------------------------------------------
30
+ # Defines the plot theme (visualization). In this theme we remove major and minor
31
+ # grids, borders and background.
32
+ #--------------------------------------------------------------------------------------
33
+
34
+ def self.global_theme
35
+ # remove major grids
36
+ global_theme = R.theme(panel__grid__major: E.element_blank())
37
+ # remove minor grids
38
+ global_theme = global_theme + R.theme(panel__grid__minor: E.element_blank)
39
+ # remove border
40
+ global_theme = global_theme + R.theme(panel__border: E.element_blank)
41
+ # remove background
42
+ global_theme = global_theme + R.theme(panel__background: E.element_blank)
43
+ # Change axis font
44
+ global_theme = global_theme +
45
+ R.theme(axis__text: E.element_text(size: 8, color: "#000080"))
46
+ end
47
+
48
+ #--------------------------------------------------------------------------------------
49
+ # Creates the graph title, properly formated for this theme
50
+ # @param title [String] The title to add to the graph
51
+ # @return textGrob that can be included in a graph
52
+ #--------------------------------------------------------------------------------------
53
+
54
+ def self.graph_title(title)
55
+ R.textGrob(
56
+ title,
57
+ gp: R.gpar(fontsize: 12, col: "#000080"),
58
+ x: R.unit(0.005, "npc"),
59
+ just: R.c("left", "bottom")
60
+ )
61
+ end
62
+
63
+ #--------------------------------------------------------------------------------------
64
+ # Creates the graph subtitle, properly formated for this theme
65
+ # @param subtitle [String] The subtitle to add to the graph
66
+ # @return textGrob that can be included in a graph
67
+ #--------------------------------------------------------------------------------------
68
+
69
+ def self.graph_subtitle(subtitle)
70
+ R.textGrob(
71
+ subtitle,
72
+ gp: R.gpar(fontsize: 10, col: "#000080"),
73
+ x: R.unit(0.005, "npc"),
74
+ just: R.c("left", "bottom")
75
+ )
76
+ end
77
+
78
+ #--------------------------------------------------------------------------------------
79
+ # Defines the axis theme (visualization)
80
+ #--------------------------------------------------------------------------------------
81
+
82
+ def self.axis_title
83
+ # format the axis title
84
+ axis_title =
85
+ R.theme(
86
+ axis__title: E.element_text(
87
+ color: "#000080",
88
+ face: "bold",
89
+ size: 8,
90
+ hjust: 1)
91
+ )
92
+ end
93
+
94
+ #--------------------------------------------------------------------------------------
95
+ # Define a theme for a bar graph
96
+ #--------------------------------------------------------------------------------------
97
+
98
+ def self.bar_theme
99
+ # remove the y axis
100
+ gr_bar_theme = R.theme(
101
+ axis__line__y: E.element_blank,
102
+ axis__text__y: E.element_blank,
103
+ axis__ticks__y: E.element_blank
104
+ )
105
+
106
+ # adjust the y axis theme
107
+ gr_bar_theme = gr_bar_theme + axis_title
108
+ end
109
+
110
+ #--------------------------------------------------------------------------------------
111
+ # Define a theme for column graphs
112
+ #--------------------------------------------------------------------------------------
113
+
114
+ def self.column_theme
115
+ # remove the x axis
116
+ gr_column_theme = R.theme(
117
+ axis__line__x: E.element_blank,
118
+ axis__text__x: E.element_blank,
119
+ axis__ticks__x: E.element_blank
120
+ )
121
+
122
+ # adjust the x axis theme
123
+ gr_column_theme = gr_column_theme + axis_title
124
+ end
125
+
126
+ end
127
+
128
+ R.awt
129
+
130
+ plot = R.grid__arrange(
131
+ LightBlueTheme.graph_title("Cars: wt x mpg"),
132
+ LightBlueTheme.graph_subtitle("1974 Motor Trend US magazine"),
133
+ R.ggplot(~:mtcars, E.aes(x: :wt, y: :mpg)) +
134
+ LightBlueTheme.global_theme + # LightBlueTheme.bar_theme +
135
+ R.geom_bar(stat: "identity", fill: "lightblue"),
136
+ ncol: 1,
137
+ heights: R.c(0.050, 0.025, 0.85, 0.05)
138
+ )
139
+
140
+ plot.print
141
+
142
+ =begin
143
+ sleep(5)
144
+
145
+ # clear the page
146
+ R.grid__newpage
147
+
148
+ # removes the window and creates a new one
149
+ # R.dev__off('')
150
+ # R.awt
151
+
152
+ (R.ggplot(R.mtcars, E.aes(x: :wt, y: :mpg)) +
153
+ R.geom_point('')).print
154
+ =end
155
+
156
+ a = gets.chomp
157
+
158
+
159
+ =begin
160
+ # Add border around the plot
161
+ # global_theme = global_theme + theme(plot.background = element_rect(colour = "black", fill=NA, size=1))
162
+
163
+ # Definir tema de gráficos de colunas
164
+ # remover o eixo x
165
+ gr_column_theme = theme(axis.line.x = element_blank(),
166
+ axis.text.x = element_blank(),
167
+ axis.ticks.x = element_blank())
168
+
169
+ # ajustar título dos eixos
170
+ gr_column_theme = gr_column_theme + axis_title
171
+
172
+ # Definir tema para gráfico composto
173
+ gr_comp_theme = axis_title
174
+
175
+ br_acc = function(valor) {
176
+ accounting(valor, big.mark = ".", decimal.mark=",")
177
+ }
178
+ =end