Module: Rust::RBindings
- Defined in:
- lib/rust/core/rust.rb,
lib/rust/core/csv.rb,
lib/rust/plots/core.rb,
lib/rust/stats/tests.rb,
lib/rust/models/anova.rb,
lib/rust/stats/effsize.rb,
lib/rust/models/regression.rb,
lib/rust/stats/correlation.rb,
lib/rust/stats/descriptive.rb,
lib/rust/external/robustbase.rb,
lib/rust/external/ggplot2/core.rb,
lib/rust/external/ggplot2/geoms.rb
Overview
Module that contains methods that allow to call R functions faster. Such methods have names resembling the ones available in R (e.g., cor, wilcox_test).
Instance Method Summary collapse
- #adjbox(*args, **options) ⇒ Object
- #aes(**options) ⇒ Object
- #aov(formula, data, **options) ⇒ Object
- #boxplot(*args, **options) ⇒ Object
- #cliff_delta(d1, d2) ⇒ Object
- #cohen_d(d1, d2, **args) ⇒ Object
- #coord_flip(**options) ⇒ Object
- #cor(d1, d2, **options) ⇒ Object
- #cor_test(d1, d2, **options) ⇒ Object
- #data_frame(*args) ⇒ Object
- #geom_bar(*arguments, **options) ⇒ Object
- #geom_boxplot(*arguments, **options) ⇒ Object
- #geom_col(*arguments, **options) ⇒ Object
- #geom_density(*arguments, **options) ⇒ Object
- #geom_histogram(*arguments, **options) ⇒ Object
- #geom_line(*arguments, **options) ⇒ Object
- #geom_point(*arguments, **options) ⇒ Object
- #ggplot(*arguments) ⇒ Object
- #labs(**options) ⇒ Object (also: #labels)
- #lm(formula, data, **options) ⇒ Object
- #lmer(formula, data, **options) ⇒ Object
- #mean(series) ⇒ Object
- #median(series) ⇒ Object
- #plot(x, y = (1..x.size).to_a, **options) ⇒ Object
- #quantile(series, percentiles = [0.0, 0.25, 0.5, 0.75, 1.0]) ⇒ Object
- #read_csv(filename, **options) ⇒ Object
- #sd(series) ⇒ Object
- #t_test(d1, d2, **args) ⇒ Object
- #var(series) ⇒ Object
- #wilcox_test(d1, d2, **args) ⇒ Object
- #write_csv(filename, dataframe, **options) ⇒ Object
Instance Method Details
#adjbox(*args, **options) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rust/external/robustbase.rb', line 30 def adjbox(*args, **) result = Rust::Plots::AdjustedBoxplot.new .each do |k, v| result[k] = v end result. args.each do |s| result.series(s) end result.show end |
#aes(**options) ⇒ Object
155 156 157 |
# File 'lib/rust/external/ggplot2/core.rb', line 155 def aes(**) Rust::Plots::GGPlot::Aes.new(**) end |
#aov(formula, data, **options) ⇒ Object
74 75 76 |
# File 'lib/rust/models/anova.rb', line 74 def aov(formula, data, **) return ANOVAModel.generate(formula, data, **) end |
#boxplot(*args, **options) ⇒ Object
362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/rust/plots/core.rb', line 362 def boxplot(*args, **) result = Rust::Plots::BoxPlot.new .each do |k, v| result[k] = v end result. args.each do |s| result.series(s) end result.show end |
#cliff_delta(d1, d2) ⇒ Object
95 96 97 |
# File 'lib/rust/stats/effsize.rb', line 95 def cliff_delta(d1, d2) Rust::EffectSize::CliffDelta.compute(d1, d2) end |
#cohen_d(d1, d2, **args) ⇒ Object
99 100 101 |
# File 'lib/rust/stats/effsize.rb', line 99 def cohen_d(d1, d2, **args) Rust::EffectSize::CohenD.compute(d1, d2) end |
#coord_flip(**options) ⇒ Object
164 165 166 |
# File 'lib/rust/external/ggplot2/core.rb', line 164 def coord_flip(**) Rust::Plots::GGPlot::FlipCoordinates.new(**) end |
#cor(d1, d2, **options) ⇒ Object
159 160 161 |
# File 'lib/rust/stats/correlation.rb', line 159 def cor(d1, d2, **) return cor_test(d1, d2, **).correlation end |
#cor_test(d1, d2, **options) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/rust/stats/correlation.rb', line 163 def cor_test(d1, d2, **) method = [:method].to_s.downcase if "pearson".start_with?(method) return Rust::Correlation::Pearson.test(d1, d2) elsif "spearman".start_with?(method) return Rust::Correlation::Spearman.test(d1, d2) elsif "kendall".start_with?(method) return Rust::Correlation::Kendall.test(d1, d2) else raise "Unsupported method #{method}" end end |
#data_frame(*args) ⇒ Object
199 200 201 |
# File 'lib/rust/core/rust.rb', line 199 def data_frame(*args) Rust::DataFrame.new(*args) end |
#geom_bar(*arguments, **options) ⇒ Object
68 69 70 |
# File 'lib/rust/external/ggplot2/geoms.rb', line 68 def (*arguments, **) return Rust::Plots::GGPlot::GeomBar.new(*arguments, **) end |
#geom_boxplot(*arguments, **options) ⇒ Object
72 73 74 |
# File 'lib/rust/external/ggplot2/geoms.rb', line 72 def geom_boxplot(*arguments, **) return Rust::Plots::GGPlot::GeomBoxplot.new(*arguments, **) end |
#geom_col(*arguments, **options) ⇒ Object
64 65 66 |
# File 'lib/rust/external/ggplot2/geoms.rb', line 64 def geom_col(*arguments, **) return Rust::Plots::GGPlot::GeomCol.new(*arguments, **) end |
#geom_density(*arguments, **options) ⇒ Object
80 81 82 |
# File 'lib/rust/external/ggplot2/geoms.rb', line 80 def geom_density(*arguments, **) return Rust::Plots::GGPlot::GeomDensity.new(*arguments, **) end |
#geom_histogram(*arguments, **options) ⇒ Object
76 77 78 |
# File 'lib/rust/external/ggplot2/geoms.rb', line 76 def geom_histogram(*arguments, **) return Rust::Plots::GGPlot::GeomHistogram.new(*arguments, **) end |
#geom_line(*arguments, **options) ⇒ Object
60 61 62 |
# File 'lib/rust/external/ggplot2/geoms.rb', line 60 def geom_line(*arguments, **) return Rust::Plots::GGPlot::GeomLine.new(*arguments, **) end |
#geom_point(*arguments, **options) ⇒ Object
56 57 58 |
# File 'lib/rust/external/ggplot2/geoms.rb', line 56 def geom_point(*arguments, **) return Rust::Plots::GGPlot::GeomPoint.new(*arguments, **) end |
#ggplot(*arguments) ⇒ Object
151 152 153 |
# File 'lib/rust/external/ggplot2/core.rb', line 151 def ggplot(*arguments) Rust::Plots::GGPlot::Plot.new(*arguments) end |
#labs(**options) ⇒ Object Also known as: labels
159 160 161 |
# File 'lib/rust/external/ggplot2/core.rb', line 159 def labs(**) Rust::Plots::GGPlot::Labels.new(**) end |
#lm(formula, data, **options) ⇒ Object
241 242 243 244 |
# File 'lib/rust/models/regression.rb', line 241 def lm(formula, data, **) independent = formula.right_part.split("+").map { |v| v.strip } return LinearRegressionModel.generate(formula.left_part, independent, data, **) end |
#lmer(formula, data, **options) ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/rust/models/regression.rb', line 246 def lmer(formula, data, **) independent = formula.right_part.split("+").map { |v| v.strip } RegressionModel.generate( LinearMixedEffectsModel, "lmer", formula.left_part, independent, data, ** ) end |
#mean(series) ⇒ Object
138 139 140 |
# File 'lib/rust/stats/descriptive.rb', line 138 def mean(series) Rust::Descriptive.mean(series) end |
#median(series) ⇒ Object
142 143 144 |
# File 'lib/rust/stats/descriptive.rb', line 142 def median(series) Rust::Descriptive.median(series) end |
#plot(x, y = (1..x.size).to_a, **options) ⇒ Object
350 351 352 353 354 355 356 357 358 359 360 |
# File 'lib/rust/plots/core.rb', line 350 def plot(x, y=(1..x.size).to_a, **) result = Rust::Plots::ScatterPlot.new(x, y) .each do |k, v| result[k] = v end result. result.show end |
#quantile(series, percentiles = [0.0, 0.25, 0.5, 0.75, 1.0]) ⇒ Object
154 155 156 |
# File 'lib/rust/stats/descriptive.rb', line 154 def quantile(series, percentiles = [0.0, 0.25, 0.5, 0.75, 1.0]) Rust::Descriptive.quantile(series, percentiles) end |
#read_csv(filename, **options) ⇒ Object
119 120 121 |
# File 'lib/rust/core/csv.rb', line 119 def read_csv(filename, **) Rust::CSV.read(filename, **) end |
#sd(series) ⇒ Object
150 151 152 |
# File 'lib/rust/stats/descriptive.rb', line 150 def sd(series) Rust::Descriptive.standard_deviation(series) end |
#t_test(d1, d2, **args) ⇒ Object
376 377 378 379 380 381 382 383 |
# File 'lib/rust/stats/tests.rb', line 376 def t_test(d1, d2, **args) paired = args[:paired] || false if paired return Rust::StatisticalTests::T.paired(d1, d2) else return Rust::StatisticalTests::T.unpaired(d1, d2) end end |
#var(series) ⇒ Object
146 147 148 |
# File 'lib/rust/stats/descriptive.rb', line 146 def var(series) Rust::Descriptive.variance(series) end |
#wilcox_test(d1, d2, **args) ⇒ Object
367 368 369 370 371 372 373 374 |
# File 'lib/rust/stats/tests.rb', line 367 def wilcox_test(d1, d2, **args) paired = args[:paired] || false if paired return Rust::StatisticalTests::Wilcoxon.paired(d1, d2) else return Rust::StatisticalTests::Wilcoxon.unpaired(d1, d2) end end |