galaaz 0.4.7 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1179 -39
  3. data/Rakefile +4 -2
  4. data/bin/grun +1 -1
  5. data/bin/gstudio +1 -1
  6. data/blogs/dev/dev.Rmd +2 -56
  7. data/blogs/dev/dev.md +32 -61
  8. data/blogs/dev/dev2.Rmd +65 -0
  9. data/blogs/dplyr/dplyr.Rmd +29 -0
  10. data/blogs/{dev/dev.html → dplyr/dplyr.html} +88 -57
  11. data/blogs/dplyr/dplyr.md +58 -0
  12. data/blogs/gknit/gknit.html +1262 -25
  13. data/blogs/gknit/gknit.md +471 -27
  14. data/blogs/gknit/gknit_files/figure-html/bubble-1.png +0 -0
  15. data/blogs/manual/graph.rb +29 -0
  16. data/blogs/manual/manual.Rmd +567 -29
  17. data/blogs/manual/manual.html +743 -46
  18. data/blogs/manual/manual.md +1179 -39
  19. data/blogs/nse_dplyr/nse_dplyr.Rmd +466 -11
  20. data/blogs/nse_dplyr/nse_dplyr.html +472 -37
  21. data/blogs/nse_dplyr/nse_dplyr.md +645 -32
  22. data/blogs/ruby_plot/ruby_plot.Rmd +4 -4
  23. data/blogs/ruby_plot/ruby_plot.html +217 -2
  24. data/blogs/ruby_plot/ruby_plot.md +226 -1
  25. data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png +0 -0
  26. data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg +2 -2
  27. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png +0 -0
  28. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg +70 -70
  29. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png +0 -0
  30. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg +72 -72
  31. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png +0 -0
  32. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg +116 -116
  33. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png +0 -0
  34. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg +176 -176
  35. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png +0 -0
  36. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png +0 -0
  37. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.svg +236 -236
  38. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png +0 -0
  39. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg +176 -176
  40. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png +0 -0
  41. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg +160 -160
  42. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png +0 -0
  43. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg +105 -105
  44. data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png +0 -0
  45. data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg +121 -121
  46. data/examples/islr/ch2.spec.rb +1 -1
  47. data/examples/islr/ch3_boston.rb +4 -4
  48. data/examples/islr/x_y_rnorm.jpg +0 -0
  49. data/lib/R_interface/r.rb +1 -1
  50. data/lib/R_interface/r_methods.rb +2 -2
  51. data/lib/R_interface/rdata_frame.rb +8 -5
  52. data/lib/R_interface/rindexed_object.rb +1 -2
  53. data/lib/R_interface/rlist.rb +1 -0
  54. data/lib/R_interface/robject.rb +0 -1
  55. data/lib/R_interface/rpkg.rb +14 -6
  56. data/lib/R_interface/rsupport.rb +7 -9
  57. data/lib/R_interface/ruby_extensions.rb +17 -5
  58. data/lib/gknit/knitr_engine.rb +9 -2
  59. data/lib/util/exec_ruby.rb +2 -2
  60. data/specs/r_dataframe.spec.rb +173 -0
  61. data/specs/r_list.spec.rb +4 -4
  62. data/specs/ruby_expression.spec.rb +2 -11
  63. data/specs/tmp.rb +76 -34
  64. data/version.rb +1 -1
  65. metadata +17 -6
  66. data/blogs/dev/dev_files/figure-html/bubble-1.png +0 -0
  67. data/blogs/dev/dev_files/figure-html/diverging_bar. +0 -0
  68. data/blogs/dev/dev_files/figure-html/diverging_bar.png +0 -0
@@ -59,7 +59,7 @@ describe R::List do
59
59
  end
60
60
 
61
61
  #----------------------------------------------------------------------------------------
62
- context "When subsetting a list with '<<' (starts at 0)" do
62
+ context "When subsetting a list with '>>' (starts at 0)" do
63
63
 
64
64
  before(:each) do
65
65
  @l = R.list(1, a: 2, b: 3, c: R.list(4, 5, 6))
@@ -170,12 +170,12 @@ describe R::List do
170
170
  expect(@l[[4]][[1]]).to eq 4
171
171
  end
172
172
 
173
- it "should subset with [[]] with multiple indexes" do
173
+ it "should subset with [[]] with a vector" do
174
174
  # Note that for a list or other recursive object, the index can be a vector
175
175
  # and each element of the vector is applied in turn to the list, the
176
176
  # selected component, the selected component of that component, and so on.
177
177
  # The result is still a single element.
178
- expect(@l[[4, 1]]).to eq 4
178
+ expect(@l[[R.c(4, 1)]]).to eq 4
179
179
  end
180
180
 
181
181
  end
@@ -230,7 +230,7 @@ describe R::List do
230
230
  end
231
231
 
232
232
  #----------------------------------------------------------------------------------------
233
- context "When modifying a list" do
233
+ context "When assigning to a list subset" do
234
234
 
235
235
  before(:each) do
236
236
  @l = R.list(a: 1, b: 2, c: 3, d: R.list(i: 4, j: 5, k: 6))
@@ -288,18 +288,9 @@ describe Symbol do
288
288
 
289
289
  # df is a Ruby symbol and ToothGrowth is an R dataframe. But at this point
290
290
  # there is no relationship between the two
291
- df = :ToothGrowth
292
-
293
- # we now call a method on a Ruby symbol. This will try to identify if this
294
- # method exists in the R dataframe. This is one of the columns of the R
295
- # dataframe, so 'dose' is now an R expression
291
+ df = ~:ToothGrowth
296
292
  dose = df.dose
297
- expect(dose.to_s).to eq "ToothGrowth[[\"dose\"]]"
298
-
299
- # dose.assign is an R expression, equivalent to 'ToothGrowth[["dose"]] <-'
300
- # an the whole expression becomes:
301
- # 'ToothGrowth[["dose"]] <- as.factor(ToothGrowth[["dose"]])'
302
- dose.assign dose.as__factor
293
+ dose = dose.as__factor
303
294
 
304
295
  df2 = R.data__frame(
305
296
  R.aggregate(df.len, by: R.list(dose), FUN: :mean),
@@ -22,55 +22,97 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
- R.require 'stats'
25
+ require 'ggplot'
26
26
 
27
- # require 'ggplot'
27
+ # R.install_and_loads('nycflights13')
28
+ # R.install_and_loads 'dplyr'
28
29
 
29
- # Need to fix function 'str'... not printing anything
30
- # anymore
31
- # puts R.str(mtcars)
32
- # shouls allow mtcars[['car name']] = mtcars.rownames
30
+ R.awt
31
+ x = R.rnorm(100)
32
+ y = R.rnorm(100)
33
+ # plot commands do not work. Need to work with ggplot or grid
34
+ # qplot uses a similar interface as plot
35
+ # Need to call print at the end of the plot
36
+ R.qplot(x, y,
37
+ xlab: "this is the x-axis",
38
+ ylab: "this is the y-axis",
39
+ main: "Plot of X vs Y")
40
+ .print
41
+ # the graphics dies when the script ends... waiting 3 secs
42
+ # so that the graphic can be seen
43
+ sleep(3)
33
44
 
34
- # (~:mtcars).str
45
+ ## Renaming columns
35
46
 
36
- describe R::List do
37
-
38
- context "The apply family of functions with lists" do
47
+ #The rename function is used to rename columns
39
48
 
49
+ #```{ruby rename}
50
+ #puts @flights.rename(dep_time: 'deptime').head.as__data__frame
51
+ #```
40
52
 
41
- x = R.list(a: (1..10), beta: R.exp(-3..3), logic: R.c(true, false, false, true))
42
- #puts x
43
53
 
44
- quant = R.lapply(x, ~:quantile)
45
- #puts quant
46
- #puts quant.a[['50,00000%']]
54
+ # puts File.directory?(".")
47
55
 
48
- # puts quant.beta['100%']
49
56
 
50
- it "ss" do
51
-
52
- ret = R.all__equal(quant.beta["100%"],
53
- R.c('100%': 20.08553692),
54
- tolerance: (~:".Machine").double__eps ** 0.5)
55
- expect(R.c(1, 2, 3)).to eq false
56
- # expect(5 == 10).to eq true
57
- end
58
- end
59
- end
60
57
 
61
- =begin
62
- # Make @q the function R quantile
63
58
 
64
- #puts quant.a
65
59
 
66
- # puts quant.a[["50%"]]
60
+ #===========================================================
61
+ =begin
62
+ # Add NULL to an element of the list
63
+ # Not implemented yet. Need to assing the
64
+ # list(NULL) element.
65
+ R::Support.eval(<<-R)
66
+ y <- list(a = 1, b = 2)
67
+ y["b"] <- list(NULL)
68
+ str(y)
69
+
70
+ print(list(NULL))
71
+ R
67
72
  =end
68
73
 
69
74
 
70
75
  =begin
71
- R::Support.eval(<<R)
72
- x = list(a = (1:10), beta = exp(-3:3), logic = c(TRUE, FALSE, FALSE, TRUE))
73
- quant = lapply(x, quantile)
74
- print(quant)
76
+ Polyglot.eval("R", <<-R)
77
+ fidx = function(idx) {
78
+ print(typeof(idx))
79
+ print(class(idx))
80
+ print(idx)
81
+ print(is_missing(idx))
82
+ }
83
+
84
+ ma = missing_arg()
85
+ f = fidx
86
+ params = list()
87
+ params = `[[<-`(params, 1, ma)
88
+ invoke(f, params)
89
+
90
+ print("======")
91
+ fidx(ma)
92
+
75
93
  R
76
94
  =end
95
+
96
+ =begin
97
+ ma = Polyglot.eval("R", "missing_arg()")
98
+
99
+ puts "======"
100
+
101
+ f = Polyglot.eval("R", "fidx")
102
+ params = Polyglot.eval("R", "list()")
103
+ params = Polyglot.eval("R", "`[[<-`").call(params, 1, ma)
104
+ Polyglot.eval("R", "invoke").call(f, params)
105
+
106
+ puts "======"
107
+
108
+ Polyglot.eval("R", "fidx").call(ma)
109
+ =end
110
+
111
+ # Polyglot.eval("R", "print").call(pl)
112
+ # ma2 = Polyglot.eval("R", "`[[`").call(pl, 1)
113
+ # Polyglot.eval("R", "fidx").call(ma2)
114
+
115
+ #R.fidx(ma)
116
+
117
+ # R.fidx(Polyglot.eval("R", "missing_arg()"))
118
+ # R.fidx(R.empty_symbol)
data/version.rb CHANGED
@@ -1,2 +1,2 @@
1
1
  $gem_name = "galaaz"
2
- $version="0.4.7"
2
+ $version="0.4.8"
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.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Botafogo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-22 00:00:00.000000000 Z
11
+ date: 2019-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -85,12 +85,12 @@ files:
85
85
  - bin/gstudio
86
86
  - bin/gstudio.rb
87
87
  - blogs/dev/dev.Rmd
88
- - blogs/dev/dev.html
89
88
  - blogs/dev/dev.md
90
- - blogs/dev/dev_files/figure-html/bubble-1.png
91
- - blogs/dev/dev_files/figure-html/diverging_bar.
92
- - blogs/dev/dev_files/figure-html/diverging_bar.png
89
+ - blogs/dev/dev2.Rmd
93
90
  - blogs/dev/model.rb
91
+ - blogs/dplyr/dplyr.Rmd
92
+ - blogs/dplyr/dplyr.html
93
+ - blogs/dplyr/dplyr.md
94
94
  - blogs/dplyr/dplyr.rb
95
95
  - blogs/galaaz_ggplot/galaaz_ggplot.Rmd
96
96
  - blogs/galaaz_ggplot/galaaz_ggplot.aux
@@ -111,6 +111,7 @@ files:
111
111
  - blogs/gknit/gknit_files/figure-html/bubble-1.png
112
112
  - blogs/gknit/gknit_files/figure-html/diverging_bar.png
113
113
  - blogs/gknit/model.rb
114
+ - blogs/manual/graph.rb
114
115
  - blogs/manual/manual.Rmd
115
116
  - blogs/manual/manual.html
116
117
  - blogs/manual/manual.md
@@ -129,16 +130,26 @@ files:
129
130
  - blogs/ruby_plot/ruby_plot.md
130
131
  - blogs/ruby_plot/ruby_plot.pdf
131
132
  - blogs/ruby_plot/ruby_plot.tex
133
+ - blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png
132
134
  - blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg
135
+ - blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png
133
136
  - blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg
137
+ - blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png
134
138
  - blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg
139
+ - blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png
135
140
  - blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg
141
+ - blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png
136
142
  - blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg
137
143
  - blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png
144
+ - blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png
138
145
  - blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.svg
146
+ - blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png
139
147
  - blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg
148
+ - blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png
140
149
  - blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg
150
+ - blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png
141
151
  - blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg
152
+ - blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png
142
153
  - blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg
143
154
  - examples/50Plots_MasterList/Images/midwest-scatterplot.PNG
144
155
  - examples/50Plots_MasterList/ScatterPlot.rb