From 500d815686fa066768b9815a84ed6e03e32f5922 Mon Sep 17 00:00:00 2001 From: alfcanr <80713668+alfcanr@users.noreply.github.com> Date: Mon, 15 Mar 2021 13:01:30 -0600 Subject: [PATCH 1/9] Update weightDataFrame.R --- R/weightDataFrame.R | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/R/weightDataFrame.R b/R/weightDataFrame.R index 59951da..65fe4b0 100644 --- a/R/weightDataFrame.R +++ b/R/weightDataFrame.R @@ -1,13 +1,11 @@ weightDataFrame <- function(data, freq){ - if (ncol(data)<2) { - stop("The data frame must contain at least two variables.") - } - if (!is.numeric(data[["freq"]])) { - stop("The freq variable should contain frequencies and must be numeric.") - } - times <- as.integer(data[[freq]]) - data[[freq]] <- NULL - result <- data[rep(seq_len(nrow(data)), times),] + reps <- data[[freq]] + data[[freq]] <- NULL + m <- as.matrix(data) + result <- as.vector(m) + result <- matrix(rep(result,rep(reps,ncol(m))),sum(reps),ncol(m)); + result <- as.data.frame(result); + colnames(result) <- colnames(data) return(result) } From 9713275bf26b4445662eba2f9bdd3e3c5bff0b3a Mon Sep 17 00:00:00 2001 From: alfcanr <80713668+alfcanr@users.noreply.github.com> Date: Mon, 15 Mar 2021 13:03:52 -0600 Subject: [PATCH 2/9] Update DESCRIPTION --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f15ef04..cd0cf54 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,8 +2,8 @@ Encoding: UTF-8 Package: rkTeaching Type: Package Title: A RKWard plugin with basic utilities for teaching Statistics -Version: 1.3.0 -Date: 2019-09-01 +Version: 1.3.3 +Date: 2020-11-01 Author: Alfredo Sánchez Alberca Maintainer: Alfredo Sánchez Alberca Enhances: rkward From 123a10756c91e06e59378936922d39f0bb332c10 Mon Sep 17 00:00:00 2001 From: alfcanr <80713668+alfcanr@users.noreply.github.com> Date: Mon, 15 Mar 2021 13:09:41 -0600 Subject: [PATCH 3/9] Update data_weighting.js --- inst/rkward/plugins/data/data_weighting.js | 33 ++++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/inst/rkward/plugins/data/data_weighting.js b/inst/rkward/plugins/data/data_weighting.js index 79611e5..b08ced5 100644 --- a/inst/rkward/plugins/data/data_weighting.js +++ b/inst/rkward/plugins/data/data_weighting.js @@ -1,23 +1,26 @@ // author: Alfredo Sánchez Alberca (asalber@ceu.es) -var dataframe, - freq, - newDataframe; -function setGlobalVars() { - dataframe = getString("dataframe"); - freq = getString("freq.shortname"); - newDataframe = getString("newDataframe"); -} +// globals +var data, newdata, freq; -function preprocess() { - setGlobalVars(); - echo("library(rkTeaching)\n"); +function preprocess(){ + // add requirements etc. here + echo("require(rkTeaching)\n"); } -function calculate() { - echo('.GlobalEnv$' + newDataframe + ' <- weightDataFrame(' + dataframe + ', "' + freq + '")\n'); +function calculate () { + data = getString("dataframe"); + newdata = getString("save"); + freq = getString("freq.shortname"); + echo ('.GlobalEnv$' + newdata + ' <- weightDataFrame(' + data + ', "' + freq + '")\n'); + // Copy also the labels of original data set + echo('for(i in 1:length(names(' + newdata + '))){\n'); + echo('\t if (names(' + newdata + ')[i]!= "' + freq + '"){\n'); + echo('\t attr(.GlobalEnv$' + newdata + '[[names(' + newdata + ')[i]]],".rk.meta") = attr(' + data + '[[names(' + newdata + ')[i]]],".rk.meta")\n'); + echo('\t }\n'); + echo('}\n'); } -function printout() { - var header = new Header(i18n("Data weighting")).addFromUI("dataframe").addFromUI("freq").addFromUI("newDataframe").print(); +function printout () { + echo ('rk.header ("Ponderación de conjunto de datos", parameters=list("Conjunto de datos a ponderar" = "' + data + '", "Frecuencias de ponderación" = "' + freq + '", "Nuevo conjunto de datos" = rk.get.description(' + newdata + ')))\n'); } From 4581b655e440af402141a4d900b5a5483abd6d0b Mon Sep 17 00:00:00 2001 From: alfcanr <80713668+alfcanr@users.noreply.github.com> Date: Mon, 15 Mar 2021 13:11:10 -0600 Subject: [PATCH 4/9] Update data_weighting.xml --- inst/rkward/plugins/data/data_weighting.xml | 52 +++++++++++---------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/inst/rkward/plugins/data/data_weighting.xml b/inst/rkward/plugins/data/data_weighting.xml index fc79a0d..efce73d 100644 --- a/inst/rkward/plugins/data/data_weighting.xml +++ b/inst/rkward/plugins/data/data_weighting.xml @@ -6,43 +6,45 @@ - - - - - - - - - + + + + + + + - - - + + + - - - + + + - Select the data frame to weight. + Seleccionar el conjunto de datos a ponderar. + - - + + - + - Select the variable that contains the weighting frequencies. + Seleccionar la variable que contiene las frecuencias de ponderación. + Debe haber tantas frecuencias como filas tenga el conjunto de datos a ponderar. + - + - + - Enter the name for the new data set. By default the new data set is saved in the .GlobalEnv environment. + Introducir un nombre para el nuevo conjunto de datos. + Por defecto el nuevo conjunto de datos se guarda en el espacio de trabajo global .GlobalEnv. + - - + From cf4f421fcdaec3d50a4861ca9cc87754c75e6064 Mon Sep 17 00:00:00 2001 From: alfcanr <80713668+alfcanr@users.noreply.github.com> Date: Mon, 15 Mar 2021 13:13:35 -0600 Subject: [PATCH 5/9] Update variable_recoding.js --- inst/rkward/plugins/data/variable_recoding.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inst/rkward/plugins/data/variable_recoding.js b/inst/rkward/plugins/data/variable_recoding.js index 2e07224..400cc72 100644 --- a/inst/rkward/plugins/data/variable_recoding.js +++ b/inst/rkward/plugins/data/variable_recoding.js @@ -19,11 +19,11 @@ function calculate() { rules = rules.replace(/\n/gi, '; ').replace(/'/g, '"'); comment("Applying the recoding rules"); echo(".GlobalEnv$" + save + " <- Recode(" + variable + ", '" + rules + "'"); - if (asfactor) { - echo(", as.factor=TRUE"); - } else { - echo(", as.factor=FALSE"); - } + //if (asfactor) { + // echo(", as.factor=TRUE"); + //} else { + // echo(", as.factor=FALSE"); + //} echo(")\n"); } From 0cb668e374a14ec2acb417ca55f1d1c9a93a3cb5 Mon Sep 17 00:00:00 2001 From: AlfCano <50886849+AlfCano@users.noreply.github.com> Date: Mon, 13 Jun 2022 19:21:32 -0500 Subject: [PATCH 6/9] Update common_functions.js The "split is not a function" error occurs when we call the split() method on a value that is not of type string. To solve the error, convert the value to a string using the toString() method before calling the split method or make sure to only call the split method on strings. https://bobbyhadz.com/blog/javascript-typeerror-string-split-is-not-a-function#:~:text=The%20%22split%20is%20not%20a,the%20split%20method%20on%20strings. --- inst/rkward/plugins/common/common_functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/rkward/plugins/common/common_functions.js b/inst/rkward/plugins/common/common_functions.js index ab5a424..d989625 100644 --- a/inst/rkward/plugins/common/common_functions.js +++ b/inst/rkward/plugins/common/common_functions.js @@ -3,6 +3,6 @@ function getDataframe(vars) { if (Array.isArray(vars)) { return vars.join().split('[[')[0]; } else { - return vars.split('[[')[0]; + return vars.toString().split('[[')[0]; } } From ecb953c5f130e11dcb8a6a5c98c750ab40dba4df Mon Sep 17 00:00:00 2001 From: AlfCano <50886849+AlfCano@users.noreply.github.com> Date: Wed, 13 Jul 2022 21:45:02 -0500 Subject: [PATCH 7/9] Update kruskal_wallis.js The QtScript has informed of an error: Script Error in file:///usr/share/rkward/phpfiles/common.js, line 31: TypeError: Cannot read property 'noquote' of undefined Backtrace: quote@file:///usr/share/rkward/phpfiles/common.js:31 makeHeaderCode@file:///usr/share/rkward/phpfiles/common.js:91 @file:///usr/share/rkward/phpfiles/common.js:113 printout@file:///home/username/R/x86_64-pc-linux-gnu-library/4.2/rkTeaching/rkward/plugins/non_parametric_tests/kruskal_wallis.js:68 do_printout@file:///usr/share/rkward/phpfiles/common.js:178 %entry@:1 --- inst/rkward/plugins/non_parametric_tests/kruskal_wallis.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/rkward/plugins/non_parametric_tests/kruskal_wallis.js b/inst/rkward/plugins/non_parametric_tests/kruskal_wallis.js index 631783c..f4b31cb 100644 --- a/inst/rkward/plugins/non_parametric_tests/kruskal_wallis.js +++ b/inst/rkward/plugins/non_parametric_tests/kruskal_wallis.js @@ -56,7 +56,7 @@ function printout() { // Header header = new Header(i18n("Kruskal-Wallis test for comparing the distribution of %1 according to %2", variableName, factorName)); header.add(i18n("Data frame"), dataframe); - header.add(i18n("Comparison of %1 according to %2", variableName, factorName)); + header.add(i18n("Comparison of"), i18n("%1 according to %2", variableName, factorName)); header.add(i18n("Null hypothesis"), i18n("There is no significant difference between the populations")); header.add(i18n("Alternative hypothesis"), i18n("There are significant difference between at least two populations")); if (grouped) { @@ -104,4 +104,4 @@ function printout() { echo('))\n'); } } -} \ No newline at end of file +} From 06c9cf5c5c19e15d0d5167fefcce3f77eb989228 Mon Sep 17 00:00:00 2001 From: alfcanr <80713668+alfcanr@users.noreply.github.com> Date: Wed, 13 Jul 2022 22:59:33 -0500 Subject: [PATCH 8/9] Update DESCRIPTION Fixed mistakes: DESCRIPTION: https://github.com/rkward-community/rk.Teaching/blob/3d6618252cfc9672cd17f76c4a640022181f0578/DESCRIPTION --- DESCRIPTION | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index cd0cf54..0f08ed8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,8 +2,8 @@ Encoding: UTF-8 Package: rkTeaching Type: Package Title: A RKWard plugin with basic utilities for teaching Statistics -Version: 1.3.3 -Date: 2020-11-01 +Version: 1.3.5 +Date: 2022-17-|3 Author: Alfredo Sánchez Alberca Maintainer: Alfredo Sánchez Alberca Enhances: rkward @@ -21,6 +21,7 @@ Depends: Hmisc, prob, ez, + multcomp, R (>= 3.5.0) Description: Basic utilities for teaching statistics. It contains procedures for: From 109ebcf24fd3c0fe0091bc9315de85960fe53242 Mon Sep 17 00:00:00 2001 From: alfcanr <80713668+alfcanr@users.noreply.github.com> Date: Wed, 13 Jul 2022 23:00:18 -0500 Subject: [PATCH 9/9] Update DESCRIPTION https://github.com/rkward-community/rk.Teaching/blob/3d6618252cfc9672cd17f76c4a640022181f0578/DESCRIPTION --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0f08ed8..75a6976 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,7 +3,7 @@ Package: rkTeaching Type: Package Title: A RKWard plugin with basic utilities for teaching Statistics Version: 1.3.5 -Date: 2022-17-|3 +Date: 2022-17-13 Author: Alfredo Sánchez Alberca Maintainer: Alfredo Sánchez Alberca Enhances: rkward