[education/rkward] /: Add support for grouping factors to descriptive stats plugin
Thomas Friedrichsmeier
null at kde.org
Thu Apr 21 15:44:24 BST 2022
Git commit e0f60fce3f0c35226bb6ae9fa6793785fda3aff3 by Thomas Friedrichsmeier.
Committed on 21/04/2022 at 14:44.
Pushed by tfry into branch 'master'.
Add support for grouping factors to descriptive stats plugin
M +4 -0 ChangeLog
M +7 -0 rkward/plugins/descriptive/descriptive_statistics.js
M +1 -0 rkward/plugins/descriptive/descriptive_statistics.rkh
M +1 -0 rkward/plugins/descriptive/descriptive_statistics.xml
https://invent.kde.org/education/rkward/commit/e0f60fce3f0c35226bb6ae9fa6793785fda3aff3
diff --git a/ChangeLog b/ChangeLog
index 1f0a1341..7d8d96e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+- Allow separate analysis by grouping factors in Analysis->Descriptive Statistics
+- Rework help start page to serve as a dashboard for common tasks
+ - TODO: finish this
+ - TODO: remove startup dialog
- Fix quirks around "Save as" for rkward output documents
--- Version 0.7.3 - Apr-21-2022
diff --git a/rkward/plugins/descriptive/descriptive_statistics.js b/rkward/plugins/descriptive/descriptive_statistics.js
index 9bbe711a..5769bbef 100644
--- a/rkward/plugins/descriptive/descriptive_statistics.js
+++ b/rkward/plugins/descriptive/descriptive_statistics.js
@@ -4,10 +4,17 @@ var constMad;
function calculate () {
var vars = getList ("x");
+ var groups = getList ("groups");
constMad = getValue ("constMad");
mad_type = getValue ("mad_type");
echo ('vars <- rk.list (' + vars.join (", ") + ')\n');
+ if (groups.length) {
+ comment("Split each input variable by grouping factor(s)");
+ echo('vars <- lapply (vars, function (x) split(x, list (' + groups.join(', ') + ')))\n');
+ comment("Convert nested list into flat list");
+ echo('vars <- unlist (vars, recursive=FALSE)\n');
+ }
echo ('results <- data.frame (' + i18n ("Object") + '=I(names (vars)))\n');
echo ('for (i in 1:length (vars)) {\n');
echo (' var <- vars[[i]]\n');
diff --git a/rkward/plugins/descriptive/descriptive_statistics.rkh b/rkward/plugins/descriptive/descriptive_statistics.rkh
index 42b49402..2fb5f133 100644
--- a/rkward/plugins/descriptive/descriptive_statistics.rkh
+++ b/rkward/plugins/descriptive/descriptive_statistics.rkh
@@ -14,6 +14,7 @@
<settings>
<caption id="tab_variables"/>
<setting id="x">Select one or more numeric vectors to analyse</setting>
+ <setting id="groups">Optionally select one or more grouping factors by which to split each input vector. The grouping factors have to be of the same length as the input vectors (and thus, all input vectors have to be of the same length, if using any grouping). If specifying more than one grouping factor, separate splits will be perfomed for each combination of values of the grouping factors.</setting>
<caption id="tab_mean_sd"/>
<setting id="mean">Should the mean value be computed?</setting>
<setting id="trim">Trim of the mean. See <link href="rkward://rhelp/mean"/></setting>
diff --git a/rkward/plugins/descriptive/descriptive_statistics.xml b/rkward/plugins/descriptive/descriptive_statistics.xml
index 1d2fed80..3c9026ec 100644
--- a/rkward/plugins/descriptive/descriptive_statistics.xml
+++ b/rkward/plugins/descriptive/descriptive_statistics.xml
@@ -12,6 +12,7 @@
</column>
<column>
<varslot multi="true" type="numeric" source="vars" id="x" num_dimensions="1" label="variable(s):" required="true" />
+ <varslot multi="true" source="vars" id="groups" num_dimensions="1" label="group by:" required="false" />
</column>
</row>
<checkbox value_unchecked="0" checked="flase" value="1" id="save_to_file" label="Save results to file" />
More information about the rkward-tracker
mailing list