galaaz 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
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,55 @@
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
+ R.set__seed(1234)
28
+
29
+ wdata = R.data__frame(
30
+ sex: R.c("F", "M").rep(each: 200).factor,
31
+ weight: R.c(R.rnorm(200, 55), R.rnorm(200,58)))
32
+
33
+ puts wdata.head
34
+
35
+ R.awt
36
+
37
+ # Histogram plot
38
+ # Change histogram fill color by group (sex)
39
+ wdata.qplot(:weight, geom: "histogram", fill: :sex)
40
+
41
+ sleep(2)
42
+ R.grid__newpage
43
+
44
+ # Density plot
45
+ # Change density plot line color by group (sex)
46
+ # change line type
47
+ wdata.qplot(:weight, geom: "density", color: :sex,
48
+ linetype: :sex)
49
+
50
+ sleep(2)
51
+ R.grid__newpage
52
+
53
+ # removes the window and creates a new one
54
+ R.dev__off
55
+
@@ -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
+ R.set__seed(1234)
28
+
29
+ wdata = R.data__frame(
30
+ sex: R.c("F", "M").rep(each: 200).factor,
31
+ weight: R.c(R.rnorm(200, 55), R.rnorm(200,58)))
32
+
33
+ puts wdata.head
34
+
35
+ # We start by creating a plot, named 'a', that we’ll finish next by adding layers
36
+ a = wdata.ggplot(E.aes(x: :weight))
37
+
38
+ # Aggregate the data by sex
39
+ mu = R.aggregate(wdata.weight, by: R.list(wdata.sex), FUN: :mean)
40
+ mu.names = R.c("sex", "grp_mean")
41
+ puts mu
42
+
43
+ R.awt
44
+
45
+ # Empirical Cumulative Density Function
46
+ print a + R.stat_ecdf
47
+
48
+ sleep(2)
49
+ R.grid__newpage
50
+
51
+ # quantile plot
52
+ print (~:mtcars).ggplot(E.aes(sample: :mpg)) + R.stat_qq
53
+
54
+ sleep(2)
55
+ R.grid__newpage
56
+
57
+
58
+ # a = gets.chomp
59
+
60
+ # removes the window and creates a new one
61
+ R.dev__off
62
+
@@ -0,0 +1,54 @@
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
+ # puts ~:mpg
28
+
29
+ b = R.ggplot(:mpg, E.aes(:fl))
30
+
31
+ R.awt
32
+
33
+ # Basic plot
34
+ print b + R.geom_bar
35
+
36
+ sleep(2)
37
+ R.grid__newpage
38
+
39
+ # Change fill color
40
+ print b + R.geom_bar(fill: "steelblue", color: "steelblue") +
41
+ R.theme_minimal
42
+
43
+ sleep(2)
44
+ R.grid__newpage
45
+
46
+
47
+ # a = gets.chomp
48
+
49
+ # removes the window and creates a new one
50
+ R.dev__off
51
+
52
+
53
+
54
+
@@ -0,0 +1,57 @@
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
+ R.set__seed(1234)
28
+
29
+ wdata = R.data__frame(
30
+ sex: R.c("F", "M").rep(each: 200).factor,
31
+ weight: R.c(R.rnorm(200, 55), R.rnorm(200,58)))
32
+
33
+ puts wdata.head
34
+
35
+ R.awt
36
+
37
+ # Basic box plot from data frame
38
+ wdata.qplot(:sex, :weight, geom: "boxplot", fill: :sex)
39
+
40
+ sleep(2)
41
+ R.grid__newpage
42
+
43
+ # Violin plot
44
+ wdata.qplot(:sex, :weight, geom: "violin")
45
+
46
+ sleep(2)
47
+ R.grid__newpage
48
+
49
+ # Dot plot
50
+ wdata.qplot(:sex, :weight, geom: "dotplot", stackdir: "center",
51
+ binaxis: "y", dotsize: 0.5)
52
+
53
+ sleep(2)
54
+ R.grid__newpage
55
+
56
+ # removes the window and creates a new one
57
+ R.dev__off
@@ -0,0 +1,67 @@
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 the data
28
+ mtcars = ~:mtcars
29
+ df = mtcars[:all, R.c("mpg", "cyl", "wt")]
30
+
31
+ # Convert cyl to a factor variable
32
+ df.cyl = R.as__factor(df.cyl)
33
+ puts df.head
34
+
35
+ R.awt
36
+
37
+ # Basic scatter plot
38
+ print R.qplot(x: :mpg, y: :wt, data: df, geom: "point")
39
+
40
+ # wait 2 seconds for the next plog
41
+ sleep(2)
42
+ # clear the page
43
+ R.grid__newpage
44
+
45
+ # Scatter plot with smoothed line
46
+ # Calling qplot on a dataframe does not require the data: parameter
47
+ # nor print
48
+ df.qplot(:mpg, :wt, geom: R.c("point", "smooth"))
49
+
50
+ # wait 2 seconds for the next plog
51
+ sleep(2)
52
+ # clear the page
53
+ R.grid__newpage
54
+
55
+ # The following code will change the color and the shape of points by groups.
56
+ # The column cyl will be used as grouping variable. In other words, the color
57
+ # and the shape of points will be changed by the levels of cyl.
58
+ df.qplot(:mpg, :wt, colour: :cyl, shape: :cyl)
59
+
60
+
61
+ # wait 2 seconds for the next plog
62
+ sleep(2)
63
+ # clear the page
64
+ R.grid__newpage
65
+
66
+ # removes the window and creates a new one
67
+ R.dev__off
@@ -0,0 +1,60 @@
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
+ R.awt
28
+
29
+ mtcars = ~:mtcars
30
+
31
+ puts mtcars
32
+
33
+ # Basic scatter plot
34
+ # Rementer that with ggplot, print is necessary to output
35
+ # the plot.
36
+ print mtcars.ggplot(E.aes(x: :wt, y: :mpg)) +
37
+ R.geom_point
38
+
39
+ sleep(2)
40
+ R.grid__newpage
41
+
42
+ # Change the point size, and shape
43
+ print mtcars.ggplot(E.aes(x: :wt, y: :mpg)) +
44
+ R.geom_point(size: 2, shape: 23)
45
+
46
+ sleep(2)
47
+ R.grid__newpage
48
+
49
+ # The function aes_string() can be used as follow:
50
+ print mtcars.ggplot(R.aes_string(x: "wt", y: "mpg")) +
51
+ R.geom_point(size: 2, shape: 10)
52
+
53
+ sleep(2)
54
+ R.grid__newpage
55
+
56
+ # a = gets.chomp
57
+
58
+
59
+ # removes the window and creates a new one
60
+ R.dev__off
@@ -0,0 +1,49 @@
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
+ diamonds = ~:diamonds
28
+
29
+ c = diamonds.ggplot(E.aes(:carat, :price))
30
+
31
+ R.awt
32
+
33
+ # Default plot
34
+ print c + R.geom_bin2d
35
+
36
+ sleep(2)
37
+ R.grid__newpage
38
+
39
+ # Change the number of bins
40
+ print c + R.geom_bin2d(bins: 15)
41
+
42
+
43
+ sleep(2)
44
+ R.grid__newpage
45
+
46
+ # a = gets.chomp
47
+
48
+ # removes the window
49
+ R.dev__off
@@ -0,0 +1,64 @@
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
+ faithful = ~:faithful
28
+ puts faithful
29
+
30
+ sp = faithful.ggplot(E.aes(x: :eruptions, y: :waiting))
31
+
32
+ R.awt
33
+
34
+ # example from ggplot contour using the z dimension
35
+ faithfuld = ~:faithfuld
36
+ print faithfuld.ggplot(E.aes(:waiting, :eruptions, z: :density)) +
37
+ R.geom_contour
38
+
39
+ sleep(2)
40
+ R.grid__newpage
41
+
42
+ # Default plot
43
+ print sp + R.geom_density_2d
44
+
45
+ sleep(2)
46
+ R.grid__newpage
47
+
48
+ # Add points
49
+ print sp + R.geom_point + R.geom_density_2d
50
+
51
+ sleep(2)
52
+ R.grid__newpage
53
+
54
+ # Use stat_density_2d with geom = "polygon"
55
+ print sp + R.geom_point +
56
+ R.stat_density_2d(E.aes_string(fill: '..level..'), geom: "polygon")
57
+
58
+ sleep(2)
59
+ R.grid__newpage
60
+
61
+ # a = gets.chomp
62
+
63
+ # removes the window
64
+ R.dev__off