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.
- checksums.yaml +7 -0
- data/README.md +32 -0
- data/Rakefile +177 -0
- data/bin/galaaz +8 -0
- data/examples/50Plots_MasterList/scatter_plot.rb +51 -0
- data/examples/baseball.csv +1 -0
- data/examples/baseball.rb +16 -0
- data/examples/ggplot.rb +178 -0
- data/examples/islr/Figure.jpg +0 -0
- data/examples/islr/all.rb +32 -0
- data/examples/islr/ch2.spec.rb +148 -0
- data/examples/islr/ch3.spec.rb +28 -0
- data/examples/islr/ch3_boston.rb +77 -0
- data/examples/islr/ch3_multiple_regression.rb +36 -0
- data/examples/islr/ch6.spec.rb +64 -0
- data/examples/paper/paper.rb +36 -0
- data/examples/sthda_ggplot/README.md +38 -0
- data/examples/sthda_ggplot/all.rb +68 -0
- data/examples/sthda_ggplot/one_variable_continuous/density_gg.rb +52 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_area.rb +61 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_density.rb +77 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_dotplot.rb +69 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_freqpoly.rb +69 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_histogram.rb +62 -0
- data/examples/sthda_ggplot/one_variable_continuous/histogram_density.rb +55 -0
- data/examples/sthda_ggplot/one_variable_continuous/stat.rb +62 -0
- data/examples/sthda_ggplot/one_variable_discrete/bar.rb +54 -0
- data/examples/sthda_ggplot/qplots/box_violin_dot.rb +57 -0
- data/examples/sthda_ggplot/qplots/scatter_plots.rb +67 -0
- data/examples/sthda_ggplot/scatter_gg.rb +60 -0
- data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_bin2d.rb +49 -0
- data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_density2d.rb +64 -0
- data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_hex.rb +52 -0
- data/examples/sthda_ggplot/two_variables_cont_cont/geom_point.rb +65 -0
- data/examples/sthda_ggplot/two_variables_cont_cont/geom_smooth.rb +66 -0
- data/examples/sthda_ggplot/two_variables_cont_cont/misc.rb +83 -0
- data/examples/sthda_ggplot/two_variables_cont_function/geom_area.rb +63 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_bar.rb +85 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_boxplot.rb +62 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_dotplot.rb +75 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_jitter.rb +74 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_line.rb +55 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_violin.rb +70 -0
- data/examples/sthda_ggplot/two_variables_disc_disc/geom_jitter.rb +40 -0
- data/examples/sthda_ggplot/two_variables_error/geom_crossbar.rb +108 -0
- data/examples/subsetting.rb +372 -0
- data/lib/expression.rb +45 -0
- data/lib/galaaz.rb +27 -0
- data/lib/r.rb +118 -0
- data/lib/r_methods.rb +89 -0
- data/lib/rbinary_operators.rb +226 -0
- data/lib/rclosure.rb +34 -0
- data/lib/rdata_frame.rb +63 -0
- data/lib/renvironment.rb +34 -0
- data/lib/rexpression.rb +34 -0
- data/lib/rindexed_object.rb +68 -0
- data/lib/rlanguage.rb +64 -0
- data/lib/rlist.rb +72 -0
- data/lib/rmatrix.rb +38 -0
- data/lib/rmd_indexed_object.rb +43 -0
- data/lib/robject.rb +297 -0
- data/lib/rpkg.rb +53 -0
- data/lib/rsupport.rb +292 -0
- data/lib/rsupport_scope.rb +77 -0
- data/lib/rsymbol.rb +57 -0
- data/lib/ruby_callback.rb +83 -0
- data/lib/ruby_extensions.rb +74 -0
- data/lib/runary_operators.rb +58 -0
- data/lib/rvector.rb +117 -0
- data/r_requires/ggplot.rb +31 -0
- data/specs/all.rb +45 -0
- data/specs/r_dataframe.spec.rb +181 -0
- data/specs/r_eval.spec.rb +164 -0
- data/specs/r_function.spec.rb +105 -0
- data/specs/r_language.spec.rb +135 -0
- data/specs/r_list.spec.rb +129 -0
- data/specs/r_list_apply.spec.rb +99 -0
- data/specs/r_matrix.spec.rb +83 -0
- data/specs/r_vector_creation.spec.rb +99 -0
- data/specs/r_vector_functions.spec.rb +59 -0
- data/specs/r_vector_object.spec.rb +94 -0
- data/specs/r_vector_operators.spec.rb +174 -0
- data/specs/r_vector_subsetting.spec.rb +136 -0
- data/specs/tmp.rb +134 -0
- data/version.rb +2 -0
- metadata +198 -0
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
Polyglot.eval("R", "library('hexbin')")
|
|
28
|
+
|
|
29
|
+
diamonds = ~:diamonds
|
|
30
|
+
|
|
31
|
+
c = diamonds.ggplot(E.aes(:carat, :price))
|
|
32
|
+
|
|
33
|
+
R.awt
|
|
34
|
+
|
|
35
|
+
# Default plot
|
|
36
|
+
print c + R.geom_hex
|
|
37
|
+
|
|
38
|
+
sleep(2)
|
|
39
|
+
R.grid__newpage
|
|
40
|
+
|
|
41
|
+
# Change the number of bins
|
|
42
|
+
print c + R.geom_hex(bins: 10)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
sleep(2)
|
|
46
|
+
R.grid__newpage
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# a = gets.chomp
|
|
50
|
+
|
|
51
|
+
# removes the window
|
|
52
|
+
R.dev__off
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
mtcars = ~:mtcars
|
|
28
|
+
mtcars.cyl = R.as__factor(mtcars.cyl)
|
|
29
|
+
puts mtcars
|
|
30
|
+
|
|
31
|
+
b = mtcars.ggplot(E.aes(x: :wt, y: :mpg))
|
|
32
|
+
|
|
33
|
+
# @bug: Next statement is not converting cyl to factor. Should investigate
|
|
34
|
+
# (~:mtcars).cyl = R.as__factor((~:mtcars).cyl)
|
|
35
|
+
# puts ~:mtcars
|
|
36
|
+
# b = R.ggplot(:mtcars, E.aes(x: :wt, y: :mpg))
|
|
37
|
+
|
|
38
|
+
R.awt
|
|
39
|
+
|
|
40
|
+
# Basic plot
|
|
41
|
+
print b + R.geom_point
|
|
42
|
+
|
|
43
|
+
sleep(2)
|
|
44
|
+
R.grid__newpage
|
|
45
|
+
|
|
46
|
+
# change the color and the point
|
|
47
|
+
# by the levels of cyl variable
|
|
48
|
+
print b + R.geom_point(E.aes(color: :cyl, shape: :cyl))
|
|
49
|
+
|
|
50
|
+
sleep(2)
|
|
51
|
+
R.grid__newpage
|
|
52
|
+
|
|
53
|
+
# Change color manually
|
|
54
|
+
print b + R.geom_point(E.aes(color: :cyl, shape: :cyl)) +
|
|
55
|
+
R.scale_color_manual(values: R.c("#999999", "#E69F00", "#56B4E9")) +
|
|
56
|
+
R.theme_minimal
|
|
57
|
+
|
|
58
|
+
sleep(2)
|
|
59
|
+
R.grid__newpage
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# a = gets.chomp
|
|
63
|
+
|
|
64
|
+
# removes the window and creates a new one
|
|
65
|
+
R.dev__off
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
mtcars = ~:mtcars
|
|
28
|
+
mtcars.cyl = R.as__factor(mtcars.cyl)
|
|
29
|
+
puts mtcars
|
|
30
|
+
|
|
31
|
+
b = mtcars.ggplot(E.aes(x: :wt, y: :mpg))
|
|
32
|
+
|
|
33
|
+
R.awt
|
|
34
|
+
|
|
35
|
+
# Regression line only
|
|
36
|
+
print b + R.geom_smooth(method: :lm)
|
|
37
|
+
|
|
38
|
+
sleep(2)
|
|
39
|
+
R.grid__newpage
|
|
40
|
+
|
|
41
|
+
# Point + regression line
|
|
42
|
+
# Remove the confidence interval
|
|
43
|
+
print b + R.geom_point +
|
|
44
|
+
R.geom_smooth(method: :lm, se: false)
|
|
45
|
+
|
|
46
|
+
sleep(2)
|
|
47
|
+
R.grid__newpage
|
|
48
|
+
|
|
49
|
+
# loess method: local regression fitting
|
|
50
|
+
print b + R.geom_point + R.geom_smooth
|
|
51
|
+
|
|
52
|
+
sleep(2)
|
|
53
|
+
R.grid__newpage
|
|
54
|
+
|
|
55
|
+
# Change color and shape by groups (cyl)
|
|
56
|
+
print b + R.geom_point(E.aes(color: :cyl, shape: :cyl)) +
|
|
57
|
+
R.geom_smooth(E.aes(color: :cyl, shape: :cyl),
|
|
58
|
+
method: :lm, se: false, fullrange: true)
|
|
59
|
+
|
|
60
|
+
sleep(2)
|
|
61
|
+
R.grid__newpage
|
|
62
|
+
|
|
63
|
+
# a = gets.chomp
|
|
64
|
+
|
|
65
|
+
# removes the window and creates a new one
|
|
66
|
+
R.dev__off
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
Polyglot.eval("R", "library('quantreg')")
|
|
28
|
+
|
|
29
|
+
R.awt
|
|
30
|
+
|
|
31
|
+
# geom_quantile(): Add quantile lines from a quantile regression
|
|
32
|
+
print R.ggplot(~:mpg, E.aes(:cty, :hwy)) +
|
|
33
|
+
R.geom_point + R.geom_quantile +
|
|
34
|
+
R.theme_minimal
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
sleep(2)
|
|
38
|
+
R.grid__newpage
|
|
39
|
+
|
|
40
|
+
print R.ggplot(~:mpg, E.aes(:cty, :hwy)) +
|
|
41
|
+
R.geom_point + R.stat_quantile(quantiles: R.c(0.25, 0.5, 0.75))
|
|
42
|
+
|
|
43
|
+
sleep(2)
|
|
44
|
+
R.grid__newpage
|
|
45
|
+
|
|
46
|
+
# geom_rug(): Add marginal rug to scatter plots
|
|
47
|
+
# Add marginal rugs using faithful data
|
|
48
|
+
|
|
49
|
+
print (~:faithful).ggplot(E.aes(x: :eruptions, y: :waiting)) +
|
|
50
|
+
R.geom_point + R.geom_rug
|
|
51
|
+
|
|
52
|
+
sleep(2)
|
|
53
|
+
R.grid__newpage
|
|
54
|
+
|
|
55
|
+
# geom_jitter(): Jitter points to reduce overplotting
|
|
56
|
+
|
|
57
|
+
plot = (~:mpg).ggplot(E.aes(:displ, :hwy))
|
|
58
|
+
|
|
59
|
+
# Default scatter plot
|
|
60
|
+
plot = plot + R.geom_point
|
|
61
|
+
|
|
62
|
+
# Use jitter to reduce overplotting
|
|
63
|
+
plot = plot + R.geom_jitter(
|
|
64
|
+
position: R.position_jitter(width: 0.5, height: 0.5))
|
|
65
|
+
print plot
|
|
66
|
+
|
|
67
|
+
sleep(2)
|
|
68
|
+
R.grid__newpage
|
|
69
|
+
|
|
70
|
+
#
|
|
71
|
+
mtcars = ~:mtcars
|
|
72
|
+
mtcars.cyl = R.as__factor(mtcars.cyl)
|
|
73
|
+
b = mtcars.ggplot(E.aes(x: :wt, y: :mpg))
|
|
74
|
+
|
|
75
|
+
print b + R.geom_text(E.aes(label: R.rownames(mtcars)))
|
|
76
|
+
|
|
77
|
+
sleep(2)
|
|
78
|
+
R.grid__newpage
|
|
79
|
+
|
|
80
|
+
# a = gets.chomp
|
|
81
|
+
|
|
82
|
+
# removes the window
|
|
83
|
+
R.dev__off
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
economics = ~:economics
|
|
28
|
+
|
|
29
|
+
d = economics.ggplot(E.aes(x: :date, y: :unemploy))
|
|
30
|
+
|
|
31
|
+
R.awt
|
|
32
|
+
|
|
33
|
+
# Area plot
|
|
34
|
+
print d + R.geom_area
|
|
35
|
+
|
|
36
|
+
sleep(2)
|
|
37
|
+
R.grid__newpage
|
|
38
|
+
|
|
39
|
+
# Line plot: connecting observations, ordered by x
|
|
40
|
+
print d + R.geom_line
|
|
41
|
+
|
|
42
|
+
sleep(2)
|
|
43
|
+
R.grid__newpage
|
|
44
|
+
|
|
45
|
+
# Connecting observations by stairs
|
|
46
|
+
# a subset of economics data set is used
|
|
47
|
+
R.set__seed(1234)
|
|
48
|
+
|
|
49
|
+
# Remember that nrow is an R::Vector. To use it in a Ruby range we
|
|
50
|
+
# need to 'pop' its value as Numeric
|
|
51
|
+
ss = economics[R.sample((1..economics.nrow.pop), 20), :all]
|
|
52
|
+
|
|
53
|
+
print ss.ggplot(E.aes(x: :date, y: :unemploy)) +
|
|
54
|
+
R.geom_step
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
sleep(2)
|
|
58
|
+
R.grid__newpage
|
|
59
|
+
|
|
60
|
+
# a = gets.chomp
|
|
61
|
+
|
|
62
|
+
# removes the window
|
|
63
|
+
R.dev__off
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
df = R.data__frame(dose: R.c("D0.5", "D1", "D2"),
|
|
28
|
+
len: R.c(4.2, 10, 29.5))
|
|
29
|
+
|
|
30
|
+
puts df.head
|
|
31
|
+
|
|
32
|
+
df2 = R.data__frame(supp: R.rep(R.c("VC", "OJ"), each: 3),
|
|
33
|
+
dose: R.rep(R.c("D0.5", "D1", "D2"), 2),
|
|
34
|
+
len: R.c(6.8, 15, 33, 4.2, 10, 29.5))
|
|
35
|
+
puts df2.head
|
|
36
|
+
|
|
37
|
+
f = df.ggplot(E.aes(x: :dose, y: :len))
|
|
38
|
+
|
|
39
|
+
R.awt
|
|
40
|
+
|
|
41
|
+
# Basic bar plot
|
|
42
|
+
print f + R.geom_bar(stat: "identity")
|
|
43
|
+
|
|
44
|
+
sleep(2)
|
|
45
|
+
R.grid__newpage
|
|
46
|
+
|
|
47
|
+
# Change fill color and add labels
|
|
48
|
+
print f + R.geom_bar(stat: "identity", fill: "steelblue") +
|
|
49
|
+
R.geom_text(E.aes(label: :len), vjust: -0.3, size: 3.5) +
|
|
50
|
+
R.theme_minimal
|
|
51
|
+
|
|
52
|
+
sleep(2)
|
|
53
|
+
R.grid__newpage
|
|
54
|
+
|
|
55
|
+
# Change bar plot line colors by groups
|
|
56
|
+
print f + R.geom_bar(E.aes(color: :dose),
|
|
57
|
+
stat: "identity", fill: "white")
|
|
58
|
+
|
|
59
|
+
sleep(2)
|
|
60
|
+
R.grid__newpage
|
|
61
|
+
|
|
62
|
+
# Change bar plot fill colors by groups
|
|
63
|
+
print f + R.geom_bar(E.aes(fill: :dose), stat: "identity")
|
|
64
|
+
|
|
65
|
+
sleep(2)
|
|
66
|
+
R.grid__newpage
|
|
67
|
+
|
|
68
|
+
g = df2.ggplot(E.aes(x: :dose, y: :len, fill: :supp))
|
|
69
|
+
|
|
70
|
+
# Stacked bar plot
|
|
71
|
+
print g + R.geom_bar(stat: "identity")
|
|
72
|
+
|
|
73
|
+
sleep(2)
|
|
74
|
+
R.grid__newpage
|
|
75
|
+
|
|
76
|
+
# Use position=position_dodge()
|
|
77
|
+
print g + R.geom_bar(stat: "identity", position: R.position_dodge)
|
|
78
|
+
|
|
79
|
+
sleep(2)
|
|
80
|
+
R.grid__newpage
|
|
81
|
+
|
|
82
|
+
# a = gets.chomp
|
|
83
|
+
|
|
84
|
+
# removes the window
|
|
85
|
+
R.dev__off
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
tooth_growth = ~:ToothGrowth
|
|
28
|
+
tooth_growth.dose = tooth_growth.dose.as__factor
|
|
29
|
+
puts tooth_growth
|
|
30
|
+
|
|
31
|
+
e = tooth_growth.ggplot(E.aes(x: :dose, y: :len))
|
|
32
|
+
|
|
33
|
+
R.awt
|
|
34
|
+
|
|
35
|
+
# Default plot
|
|
36
|
+
print e + R.geom_boxplot
|
|
37
|
+
|
|
38
|
+
sleep(2)
|
|
39
|
+
R.grid__newpage
|
|
40
|
+
|
|
41
|
+
# Notched box plot
|
|
42
|
+
print e + R.geom_boxplot(notch: true)
|
|
43
|
+
|
|
44
|
+
sleep(2)
|
|
45
|
+
R.grid__newpage
|
|
46
|
+
|
|
47
|
+
# Color by group (dose)
|
|
48
|
+
print e + R.geom_boxplot(E.aes(color: :dose))
|
|
49
|
+
|
|
50
|
+
sleep(2)
|
|
51
|
+
R.grid__newpage
|
|
52
|
+
|
|
53
|
+
# Change fill color by group (dose)
|
|
54
|
+
print e + R.geom_boxplot(E.aes(fill: :dose))
|
|
55
|
+
|
|
56
|
+
sleep(2)
|
|
57
|
+
R.grid__newpage
|
|
58
|
+
|
|
59
|
+
# a = gets.chomp
|
|
60
|
+
|
|
61
|
+
# removes the window
|
|
62
|
+
R.dev__off
|