From bff5c16c200125ff2544de8341cd70740c17fd10 Mon Sep 17 00:00:00 2001 From: Z_Wael Date: Sat, 12 Jun 2021 16:00:11 +0200 Subject: [PATCH 1/2] just a proposition to have tables with ordered levels My proposition for Ordering levels of the categorical variable in the loop resulting in tables with decreasing ordered levels easily readable --- R/modules-constructors.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/modules-constructors.R b/R/modules-constructors.R index 206209e..fefb29d 100644 --- a/R/modules-constructors.R +++ b/R/modules-constructors.R @@ -162,6 +162,10 @@ ModuleCreateTableForOneVar <- function(x) { # Give a vector ## Reorder variables freq <- freq[c("n","miss","p.miss","level","freq","percent","cum.percent")] + + ## Ordering levels of the categorical variable in the loop + ord = order(freq$percent,decreasing = TRUE) + freq = freq[ord,] ## Return result as a data frame return(freq) From 737dc28751913c1162c0e383242f84d5dbd884a2 Mon Sep 17 00:00:00 2001 From: Z_Wael Date: Sun, 13 Jun 2021 18:39:29 +0200 Subject: [PATCH 2/2] ordering commit test2 re-ordering commit 1 failed in travis ci api new pull request in a new branch --- R/modules-constructors.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/modules-constructors.R b/R/modules-constructors.R index fefb29d..0f97dda 100644 --- a/R/modules-constructors.R +++ b/R/modules-constructors.R @@ -163,8 +163,9 @@ ModuleCreateTableForOneVar <- function(x) { # Give a vector ## Reorder variables freq <- freq[c("n","miss","p.miss","level","freq","percent","cum.percent")] - ## Ordering levels of the categorical variable in the loop + ## Ordering the levels of the categorical variable in the loop ord = order(freq$percent,decreasing = TRUE) + ## ordreing the table of the categorical variable freq = freq[ord,] ## Return result as a data frame