From 894179ff345286535b47c79d2dbbcca3b740fbf5 Mon Sep 17 00:00:00 2001 From: Kei Saito Date: Wed, 1 Mar 2023 09:07:34 -0800 Subject: [PATCH 1/2] Update the small.mark default for cut output formatter --- DESCRIPTION | 4 ++-- R/util.R | 4 ++-- tests/testthat/test_util.R | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fb5034cff..5b9de9dcb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: exploratory Type: Package Title: R package for Exploratory -Version: 6.12.3.4 -Date: 2023-02-12 +Version: 6.12.3.5 +Date: 2023-03-01 Authors@R: c(person("Hideaki", "Hayashi", email = "hideaki@exploratory.io", role = c("aut", "cre")), person("Hide", "Kojima", email = "hide@exploratory.io", role = c("aut")), person("Kan", "Nishida", email = "kan@exploratory.io", role = c("aut")), person("Kei", "Saito", email = "kei@exploratory.io", role = c("aut")), person("Yosuke", "Yasuda", email = "double.y.919.quick@gmail.com", role = c("aut"))) URL: https://github.com/exploratory-io/exploratory_func Description: Functions for Exploratory diff --git a/R/util.R b/R/util.R index 8a96e3cb0..f68251a75 100644 --- a/R/util.R +++ b/R/util.R @@ -3017,7 +3017,7 @@ construct_new_labels <- function(base.labels, new.labels) { # Example # Input: "(0.996,2.33]", "(2.33,3.67]", "(3.67,5]" # Output: "0.996 - 2.33", "2.33 - 3.67", "3.67 - 5" -format_cut_output <- function(x, decimal.digits=2, big.mark=",", small.mark=".", new.labels=NULL, prefix="", suffix="", right=TRUE) { +format_cut_output <- function(x, decimal.digits=2, big.mark=",", small.mark="", new.labels=NULL, prefix="", suffix="", right=TRUE) { # Exit if the length is 0. if (length(x) == 0 || all(is.na(x))) { return (x) @@ -3045,7 +3045,7 @@ format_cut_output <- function(x, decimal.digits=2, big.mark=",", small.mark=".", # Input: [1] "(0.996,2.333333333]" "(2.333333333,3.666666667]" "(3.666666667,5.004]" # Output: [1] "1.00 - 2.33" "2.33 - 3.67" "3.67 - 5.00" # -format_cut_output_levels <- function(x, decimal.digits=2, big.mark=",", small.mark=".", prefix="", suffix="", right=TRUE) { +format_cut_output_levels <- function(x, decimal.digits=2, big.mark=",", small.mark="", prefix="", suffix="", right=TRUE) { # Split the text by ",". It will breaks the vector like this. # [[1]] # [1] "(0.996" "2.333333333]" diff --git a/tests/testthat/test_util.R b/tests/testthat/test_util.R index f8f13f248..fafa2a65f 100644 --- a/tests/testthat/test_util.R +++ b/tests/testthat/test_util.R @@ -1746,6 +1746,12 @@ test_that("format_cut_output function", { formatted <- format_cut_output(x) expect_equal(formatted, factor(c("1.00 - 2.33","1.00 - 2.33","2.33 - 3.67","3.67 - 5.00","3.67 - 5.00"))) + # decimal.digits is more than 6 case. + # It shouldn't show the small mark "." between 6th and 7th decimal digit + # like "0.996000.00". #27137. + formatted <- `_tam_format_cut_output`(x, decimal.digits=8) + expect_equal(formatted, factor(c("0.99600000 - 2.33333333", "0.99600000 - 2.33333333", "2.33333333 - 3.66666667", "3.66666667 - 5.00400000","3.66666667 - 5.00400000"))) + # Negative test expect_equal(c(NA,NA,NA), format_cut_output(c(NA,NA,NA), decimal.digits=2)) expect_equal(NULL, format_cut_output(c(), decimal.digits=2)) From 16492f9968a53649b30dd859c348027691dadf09 Mon Sep 17 00:00:00 2001 From: Kei Saito Date: Wed, 1 Mar 2023 11:41:32 -0800 Subject: [PATCH 2/2] revert verrsion --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5b9de9dcb..fb5034cff 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: exploratory Type: Package Title: R package for Exploratory -Version: 6.12.3.5 -Date: 2023-03-01 +Version: 6.12.3.4 +Date: 2023-02-12 Authors@R: c(person("Hideaki", "Hayashi", email = "hideaki@exploratory.io", role = c("aut", "cre")), person("Hide", "Kojima", email = "hide@exploratory.io", role = c("aut")), person("Kan", "Nishida", email = "kan@exploratory.io", role = c("aut")), person("Kei", "Saito", email = "kei@exploratory.io", role = c("aut")), person("Yosuke", "Yasuda", email = "double.y.919.quick@gmail.com", role = c("aut"))) URL: https://github.com/exploratory-io/exploratory_func Description: Functions for Exploratory