Re: [R] grDevices::hcl.colors using two colours: Bug or Feature?
On Fri, 28 Apr 2023, Duncan Murdoch wrote: On 28/04/2023 6:18 a.m., Achim Zeileis wrote: On Fri, 28 Apr 2023, Achim Zeileis wrote: This was introduced in 4.3.0 (hence Rui cannot reproduce it in 4.2.3). It's a bug and was introduced when fixing this other bug: https://bugs.R-project.org/show_bug.cgi?id=18476 https://hypatia.math.ethz.ch/pipermail/r-help/2023-February/476960.html Apparently, it only affects the case with n = 2 for diverging and divergingx palettes. The culprit is this line: i <- if(n2 == 1L) 0 else seq.int(1, by = -2/(n - 1), length.out = n2) I think n2 == 1L is not the right condition and we need to distinguish n = 1 and n = 2. I think the solution is simply to use n == 1L instead of n2 == 1L, both in "diverging" (line 188 in hcl.colors.R) and "divergingx" (line 197). Duncan, maybe you can have a look at this as well? I agree that the two changes solve this problem. I couldn't spot any other places that would need fixing. Great, thanks for checking. I reported the problem with the corresponding patch at: https://bugs.R-project.org/show_bug.cgi?id=18523 Thanks & best wishes, Achim Will have a closer look... Thanks for reporting this! Achim On Fri, 28 Apr 2023, Rui Barradas wrote: Às 06:01 de 28/04/2023, Stevie Pederson escreveu: Hi, I'm not sure if this is a bug or a feature, but after updating to Rv4.3, if requesting two colours from hcl.colors() you now get the same colour twice. This occurs for all palettes I've tried. My reprex: hcl.colors(2, "Vik") [1] "#F1F1F1" "#F1F1F1" As I have multiple workflows I run repeatedly with A vs B comparisons, this has just broken the visualisations in many of them. Obviously a workaround is hcl.colors(3, "Vik")[c(1, 3)] but this seems rather unintuitive. Thanks in advance, Stevie sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.6 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C time zone: Australia/Adelaide tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 tools_4.3.0 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, I cannot reproduce this on Windows. hcl.colors(2, "Vik") # [1] "#002E60" "#3E2000" clrs <- sapply(hcl.pals(), \(p) hcl.colors(2, p)) any(apply(clrs, 2, \(x) x[1] == x[2])) # [1] FALSE sessionInfo() # R version 4.2.3 (2023-03-15 ucrt) # Platform: x86_64-w64-mingw32/x64 (64-bit) # Running under: Windows 10 x64 (build 22621) # # Matrix products: default # # locale: # [1] LC_COLLATE=Portuguese_Portugal.utf8 LC_CTYPE=Portuguese_Portugal.utf8 # [3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C # [5] LC_TIME=Portuguese_Portugal.utf8 # # attached base packages: # [1] stats graphics grDevices utils datasets methods base # # loaded via a namespace (and not attached): # [1] compiler_4.2.3 Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] grubbs test to detect all outliers
Às 14:09 de 28/04/2023, AbouEl-Makarim Aboueissa escreveu: *R: *Grubbs Test to detect all outliers Per group for all columns in a data frame Dear All: good morning I have a dataset (as an example) with two column factors (factor1 and factor2) and 5 numerical columns (X,Y,Z,U,V). The X and Y columns have same length as factor1; and Z, U, and V have same length as factor2. Please see dataset is copied below. Please note that all dataset columns have NAs values. *Need help on this:* Can we use the grubbs.test() function to detect all outliers and replace it by NA in X and Y datasets per group in factor1; and in Z, U, and V datasets per group in factor2. Columns in the dataframe have different lengths, but when I read the .csv file, R added NA values for the shorter columns. If you need the .csv data file, please let me know. Thank you very much for your help in advance. install.packages("outliers") library(outliers) datafortest<-read.csv("G:/data_for_test.csv", header=TRUE) datafortest datafortest<-data.frame(datafortest) datafortest$factor1<-as.factor(datafortest$factor1) datafortest$factor2<-as.factor(datafortest$factor2) str(datafortest) # tried to use grubbs.test() on a single column of the dataframe, but still not working tests.for.outliers.X<- grubbs.test(datafortest$X, na.rm = TRUE, type=11) *grubbs.test() on a single dataset: but this can only detect if the min and the max are outliers.* xx999<-c(0.088,1,2,3,4,5,6,7,8,9,88,98,99) grubbs.test(xx999, type=11) With many thanks Abou factor1 XY factor2 Z U V 1 4455.077 888 1 999 NA 999 1 4348.031 333 1 475NA 240 1.789 618 1 507 252 394 13813.139 417 1 603 332 265 1 7512.65 344 1 442 216 NA 1 5642.667NA 1 486 217 275 1 6684.386 341 1 927 698 479 2 5165.731 999 1 971 311 562 2 NA 265 1 388 999 512 2 3259.241 557 2 888 444 777 2 3288.383 234 2 514NA 322 2 1997.878 383 2 409 311 NA 2 0.61 NA 2 546 327 728 2 2655.977 NA 2 523 228 653 3 3189.49 2 313 456 450 3 1826.851 287 2 296 412 576 3 4386.002 352 2 320 251 NA 3 3295.091 308 2 388 888 396.5 3 2120.902 526 3 398 888 3 NA 489 3 677 438 307 3 2056.123 291 3 555 428 219 3 1995.088 444 3 NA 319 NA 3 NA 349 3 479 NA 321 3 2539.873 333 3 257 406 417 3 313 334 409 3 296 465 546 3 320 180 523 3 388 999 313 __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Mathematics and Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, Please post the output of dput(datafortest) your data is difficult to read into a R session. Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] grubbs test to detect all outliers
*R: *Grubbs Test to detect all outliers Per group for all columns in a data frame Dear All: good morning I have a dataset (as an example) with two column factors (factor1 and factor2) and 5 numerical columns (X,Y,Z,U,V). The X and Y columns have same length as factor1; and Z, U, and V have same length as factor2. Please see dataset is copied below. Please note that all dataset columns have NAs values. *Need help on this:* Can we use the grubbs.test() function to detect all outliers and replace it by NA in X and Y datasets per group in factor1; and in Z, U, and V datasets per group in factor2. Columns in the dataframe have different lengths, but when I read the .csv file, R added NA values for the shorter columns. If you need the .csv data file, please let me know. Thank you very much for your help in advance. install.packages("outliers") library(outliers) datafortest<-read.csv("G:/data_for_test.csv", header=TRUE) datafortest datafortest<-data.frame(datafortest) datafortest$factor1<-as.factor(datafortest$factor1) datafortest$factor2<-as.factor(datafortest$factor2) str(datafortest) # tried to use grubbs.test() on a single column of the dataframe, but still not working tests.for.outliers.X<- grubbs.test(datafortest$X, na.rm = TRUE, type=11) *grubbs.test() on a single dataset: but this can only detect if the min and the max are outliers.* xx999<-c(0.088,1,2,3,4,5,6,7,8,9,88,98,99) grubbs.test(xx999, type=11) With many thanks Abou factor1 XY factor2 Z U V 1 4455.077 888 1 999 NA 999 1 4348.031 333 1 475NA 240 1.789 618 1 507 252 394 13813.139 417 1 603 332 265 1 7512.65 344 1 442 216 NA 1 5642.667NA 1 486 217 275 1 6684.386 341 1 927 698 479 2 5165.731 999 1 971 311 562 2 NA 265 1 388 999 512 2 3259.241 557 2 888 444 777 2 3288.383 234 2 514NA 322 2 1997.878 383 2 409 311 NA 2 0.61 NA 2 546 327 728 2 2655.977 NA 2 523 228 653 3 3189.49 2 313 456 450 3 1826.851 287 2 296 412 576 3 4386.002 352 2 320 251 NA 3 3295.091 308 2 388 888 396.5 3 2120.902 526 3 398 888 3 NA 489 3 677 438 307 3 2056.123 291 3 555 428 219 3 1995.088 444 3 NA 319 NA 3 NA 349 3 479 NA 321 3 2539.873 333 3 257 406 417 3 313 334 409 3 296 465 546 3 320 180 523 3 388 999 313 __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Mathematics and Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] grDevices::hcl.colors using two colours: Bug or Feature?
On 28/04/2023 6:18 a.m., Achim Zeileis wrote: On Fri, 28 Apr 2023, Achim Zeileis wrote: This was introduced in 4.3.0 (hence Rui cannot reproduce it in 4.2.3). It's a bug and was introduced when fixing this other bug: https://bugs.R-project.org/show_bug.cgi?id=18476 https://hypatia.math.ethz.ch/pipermail/r-help/2023-February/476960.html Apparently, it only affects the case with n = 2 for diverging and divergingx palettes. The culprit is this line: i <- if(n2 == 1L) 0 else seq.int(1, by = -2/(n - 1), length.out = n2) I think n2 == 1L is not the right condition and we need to distinguish n = 1 and n = 2. I think the solution is simply to use n == 1L instead of n2 == 1L, both in "diverging" (line 188 in hcl.colors.R) and "divergingx" (line 197). Duncan, maybe you can have a look at this as well? I agree that the two changes solve this problem. I couldn't spot any other places that would need fixing. Duncan Murdoch Will have a closer look... Thanks for reporting this! Achim On Fri, 28 Apr 2023, Rui Barradas wrote: Às 06:01 de 28/04/2023, Stevie Pederson escreveu: Hi, I'm not sure if this is a bug or a feature, but after updating to Rv4.3, if requesting two colours from hcl.colors() you now get the same colour twice. This occurs for all palettes I've tried. My reprex: hcl.colors(2, "Vik") [1] "#F1F1F1" "#F1F1F1" As I have multiple workflows I run repeatedly with A vs B comparisons, this has just broken the visualisations in many of them. Obviously a workaround is hcl.colors(3, "Vik")[c(1, 3)] but this seems rather unintuitive. Thanks in advance, Stevie sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.6 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C time zone: Australia/Adelaide tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 tools_4.3.0 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, I cannot reproduce this on Windows. hcl.colors(2, "Vik") # [1] "#002E60" "#3E2000" clrs <- sapply(hcl.pals(), \(p) hcl.colors(2, p)) any(apply(clrs, 2, \(x) x[1] == x[2])) # [1] FALSE sessionInfo() # R version 4.2.3 (2023-03-15 ucrt) # Platform: x86_64-w64-mingw32/x64 (64-bit) # Running under: Windows 10 x64 (build 22621) # # Matrix products: default # # locale: # [1] LC_COLLATE=Portuguese_Portugal.utf8 LC_CTYPE=Portuguese_Portugal.utf8 # [3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C # [5] LC_TIME=Portuguese_Portugal.utf8 # # attached base packages: # [1] stats graphics grDevices utils datasets methods base # # loaded via a namespace (and not attached): # [1] compiler_4.2.3 Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] grDevices::hcl.colors using two colours: Bug or Feature?
Thank you all for the rapid responses & testing. I was aware of the n>=3 limit in RColorBrewer::brewer.pal so wasn't quite sure if it was a new constraint introduced intentionally. Glad to have been helpful in finding this too. All the best On Fri, 28 Apr 2023 at 19:53, Rui Barradas wrote: > Às 11:07 de 28/04/2023, Achim Zeileis escreveu: > > This was introduced in 4.3.0 (hence Rui cannot reproduce it in 4.2.3). > > > > It's a bug and was introduced when fixing this other bug: > > > > https://bugs.R-project.org/show_bug.cgi?id=18476 > > https://hypatia.math.ethz.ch/pipermail/r-help/2023-February/476960.html > > > > Apparently, it only affects the case with n = 2 for diverging and > > divergingx palettes. The culprit is this line: > > > > i <- if(n2 == 1L) 0 else seq.int(1, by = -2/(n - 1), length.out = n2) > > > > I think n2 == 1L is not the right condition and we need to distinguish n > > = 1 and n = 2. > > > > Will have a closer look... > > > > Thanks for reporting this! > > Achim > > > > On Fri, 28 Apr 2023, Rui Barradas wrote: > > > >> Às 06:01 de 28/04/2023, Stevie Pederson escreveu: > >>> Hi, > >>> > >>> I'm not sure if this is a bug or a feature, but after updating to > >>> Rv4.3, if > >>> requesting two colours from hcl.colors() you now get the same colour > >>> twice. > >>> This occurs for all palettes I've tried. My reprex: > >>> > >>> hcl.colors(2, "Vik") > >>> [1] "#F1F1F1" "#F1F1F1" > >>> > >>> As I have multiple workflows I run repeatedly with A vs B > >>> comparisons, this > >>> has just broken the visualisations in many of them. Obviously a > >>> workaround is hcl.colors(3, "Vik")[c(1, 3)] but this seems rather > >>> unintuitive. > >>> > >>> Thanks in advance, > >>> > >>> Stevie > >>> > >>> sessionInfo() > >>> R version 4.3.0 (2023-04-21) > >>> Platform: x86_64-pc-linux-gnu (64-bit) > >>> Running under: Ubuntu 20.04.6 LTS > >>> > >>> Matrix products: default > >>> BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 > >>> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 > >>> > >>> locale: > >>> [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C > >>> [3] LC_TIME=en_AU.UTF-8LC_COLLATE=en_AU.UTF-8 > >>> [5] LC_MONETARY=en_AU.UTF-8LC_MESSAGES=en_AU.UTF-8 > >>> [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C > >>> [9] LC_ADDRESS=C LC_TELEPHONE=C > >>> [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C > >>> > >>> time zone: Australia/Adelaide > >>> tzcode source: system (glibc) > >>> > >>> attached base packages: > >>> [1] stats graphics grDevices utils datasets methods base > >>> > >>> loaded via a namespace (and not attached): > >>> [1] compiler_4.3.0 tools_4.3.0 > >>> > >>> [[alternative HTML version deleted]] > >>> > >>> __ > >>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >>> https://stat.ethz.ch/mailman/listinfo/r-help > >>> PLEASE do read the posting guide > >>> http://www.R-project.org/posting-guide.html > >>> and provide commented, minimal, self-contained, reproducible code. > >> Hello, > >> > >> I cannot reproduce this on Windows. > >> > >> > >> hcl.colors(2, "Vik") > >> # [1] "#002E60" "#3E2000" > >> > >> clrs <- sapply(hcl.pals(), \(p) hcl.colors(2, p)) > >> any(apply(clrs, 2, \(x) x[1] == x[2])) > >> # [1] FALSE > >> > >> sessionInfo() > >> # R version 4.2.3 (2023-03-15 ucrt) > >> # Platform: x86_64-w64-mingw32/x64 (64-bit) > >> # Running under: Windows 10 x64 (build 22621) > >> # > >> # Matrix products: default > >> # > >> # locale: > >> # [1] LC_COLLATE=Portuguese_Portugal.utf8 > >> LC_CTYPE=Portuguese_Portugal.utf8 > >> # [3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C > >> # [5] LC_TIME=Portuguese_Portugal.utf8 > >> # > >> # attached base packages: > >> # [1] stats graphics grDevices utils datasets methods base > >> # > >> # loaded via a namespace (and not attached): > >> # [1] compiler_4.2.3 > >> > >> > >> Hope this helps, > >> > >> Rui Barradas > >> > >> __ > >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >> https://stat.ethz.ch/mailman/listinfo/r-help > >> PLEASE do read the posting guide > >> http://www.R-project.org/posting-guide.html > >> and provide commented, minimal, self-contained, reproducible code. > >> > > Hello, > > Right! I ran the wrong R version, here it is with R 4.3.0. > The bug is now reproducible on Windows 11. > > > hcl.colors(2, "Vik") > # [1] "#F1F1F1" "#F1F1F1" > > clrs <- sapply(hcl.pals(), \(p) hcl.colors(2, p)) > any(apply(clrs, 2, \(x) x[1] == x[2])) > # [1] TRUE > > sum(apply(clrs, 2, \(x) x[1] == x[2])) > # [1] 35 > > which(apply(clrs, 2, \(x) x[1] == x[2])) > # Blue-RedBlue-Red 2Blue-Red 3 Red-Green Purple-Green > #8081828384 > # Purple-Brown Green-Brown Blue-Yellow 2 Blue-Yellow 3 Green-Orange > #85868788
Re: [R] grDevices::hcl.colors using two colours: Bug or Feature?
Às 11:07 de 28/04/2023, Achim Zeileis escreveu: This was introduced in 4.3.0 (hence Rui cannot reproduce it in 4.2.3). It's a bug and was introduced when fixing this other bug: https://bugs.R-project.org/show_bug.cgi?id=18476 https://hypatia.math.ethz.ch/pipermail/r-help/2023-February/476960.html Apparently, it only affects the case with n = 2 for diverging and divergingx palettes. The culprit is this line: i <- if(n2 == 1L) 0 else seq.int(1, by = -2/(n - 1), length.out = n2) I think n2 == 1L is not the right condition and we need to distinguish n = 1 and n = 2. Will have a closer look... Thanks for reporting this! Achim On Fri, 28 Apr 2023, Rui Barradas wrote: Às 06:01 de 28/04/2023, Stevie Pederson escreveu: Hi, I'm not sure if this is a bug or a feature, but after updating to Rv4.3, if requesting two colours from hcl.colors() you now get the same colour twice. This occurs for all palettes I've tried. My reprex: hcl.colors(2, "Vik") [1] "#F1F1F1" "#F1F1F1" As I have multiple workflows I run repeatedly with A vs B comparisons, this has just broken the visualisations in many of them. Obviously a workaround is hcl.colors(3, "Vik")[c(1, 3)] but this seems rather unintuitive. Thanks in advance, Stevie sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.6 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8 LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C time zone: Australia/Adelaide tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 tools_4.3.0 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, I cannot reproduce this on Windows. hcl.colors(2, "Vik") # [1] "#002E60" "#3E2000" clrs <- sapply(hcl.pals(), \(p) hcl.colors(2, p)) any(apply(clrs, 2, \(x) x[1] == x[2])) # [1] FALSE sessionInfo() # R version 4.2.3 (2023-03-15 ucrt) # Platform: x86_64-w64-mingw32/x64 (64-bit) # Running under: Windows 10 x64 (build 22621) # # Matrix products: default # # locale: # [1] LC_COLLATE=Portuguese_Portugal.utf8 LC_CTYPE=Portuguese_Portugal.utf8 # [3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C # [5] LC_TIME=Portuguese_Portugal.utf8 # # attached base packages: # [1] stats graphics grDevices utils datasets methods base # # loaded via a namespace (and not attached): # [1] compiler_4.2.3 Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, Right! I ran the wrong R version, here it is with R 4.3.0. The bug is now reproducible on Windows 11. hcl.colors(2, "Vik") # [1] "#F1F1F1" "#F1F1F1" clrs <- sapply(hcl.pals(), \(p) hcl.colors(2, p)) any(apply(clrs, 2, \(x) x[1] == x[2])) # [1] TRUE sum(apply(clrs, 2, \(x) x[1] == x[2])) # [1] 35 which(apply(clrs, 2, \(x) x[1] == x[2])) # Blue-RedBlue-Red 2Blue-Red 3 Red-Green Purple-Green #8081828384 # Purple-Brown Green-Brown Blue-Yellow 2 Blue-Yellow 3 Green-Orange #8586878889 # Cyan-MagentaTropic Broc Cork Vik #9091929394 #BerlinLisbonTofino Earth Fall #95969799 100 #Geyser TealRose Temps PuOr RdBu # 101 102 103 104 105 # RdGy PiYG PRGn BrBGRdYlBu # 106 107 108 109 110 #RdYlGn Spectral Zissou 1 Cividis Roma # 111 112 113 114 115 sessionInfo() # R version 4.3.0 (2023-04-21 ucrt) # Platform: x86_64-w64-mingw32/x64 (64-bit) # Running under: Windows 11 x64 (build 22621) # # Matrix products: default # # # locale: #
Re: [R] grDevices::hcl.colors using two colours: Bug or Feature?
On Fri, 28 Apr 2023, Achim Zeileis wrote: This was introduced in 4.3.0 (hence Rui cannot reproduce it in 4.2.3). It's a bug and was introduced when fixing this other bug: https://bugs.R-project.org/show_bug.cgi?id=18476 https://hypatia.math.ethz.ch/pipermail/r-help/2023-February/476960.html Apparently, it only affects the case with n = 2 for diverging and divergingx palettes. The culprit is this line: i <- if(n2 == 1L) 0 else seq.int(1, by = -2/(n - 1), length.out = n2) I think n2 == 1L is not the right condition and we need to distinguish n = 1 and n = 2. I think the solution is simply to use n == 1L instead of n2 == 1L, both in "diverging" (line 188 in hcl.colors.R) and "divergingx" (line 197). Duncan, maybe you can have a look at this as well? Will have a closer look... Thanks for reporting this! Achim On Fri, 28 Apr 2023, Rui Barradas wrote: Às 06:01 de 28/04/2023, Stevie Pederson escreveu: Hi, I'm not sure if this is a bug or a feature, but after updating to Rv4.3, if requesting two colours from hcl.colors() you now get the same colour twice. This occurs for all palettes I've tried. My reprex: hcl.colors(2, "Vik") [1] "#F1F1F1" "#F1F1F1" As I have multiple workflows I run repeatedly with A vs B comparisons, this has just broken the visualisations in many of them. Obviously a workaround is hcl.colors(3, "Vik")[c(1, 3)] but this seems rather unintuitive. Thanks in advance, Stevie sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.6 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C time zone: Australia/Adelaide tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 tools_4.3.0 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, I cannot reproduce this on Windows. hcl.colors(2, "Vik") # [1] "#002E60" "#3E2000" clrs <- sapply(hcl.pals(), \(p) hcl.colors(2, p)) any(apply(clrs, 2, \(x) x[1] == x[2])) # [1] FALSE sessionInfo() # R version 4.2.3 (2023-03-15 ucrt) # Platform: x86_64-w64-mingw32/x64 (64-bit) # Running under: Windows 10 x64 (build 22621) # # Matrix products: default # # locale: # [1] LC_COLLATE=Portuguese_Portugal.utf8 LC_CTYPE=Portuguese_Portugal.utf8 # [3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C # [5] LC_TIME=Portuguese_Portugal.utf8 # # attached base packages: # [1] stats graphics grDevices utils datasets methods base # # loaded via a namespace (and not attached): # [1] compiler_4.2.3 Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] grDevices::hcl.colors using two colours: Bug or Feature?
This was introduced in 4.3.0 (hence Rui cannot reproduce it in 4.2.3). It's a bug and was introduced when fixing this other bug: https://bugs.R-project.org/show_bug.cgi?id=18476 https://hypatia.math.ethz.ch/pipermail/r-help/2023-February/476960.html Apparently, it only affects the case with n = 2 for diverging and divergingx palettes. The culprit is this line: i <- if(n2 == 1L) 0 else seq.int(1, by = -2/(n - 1), length.out = n2) I think n2 == 1L is not the right condition and we need to distinguish n = 1 and n = 2. Will have a closer look... Thanks for reporting this! Achim On Fri, 28 Apr 2023, Rui Barradas wrote: Às 06:01 de 28/04/2023, Stevie Pederson escreveu: Hi, I'm not sure if this is a bug or a feature, but after updating to Rv4.3, if requesting two colours from hcl.colors() you now get the same colour twice. This occurs for all palettes I've tried. My reprex: hcl.colors(2, "Vik") [1] "#F1F1F1" "#F1F1F1" As I have multiple workflows I run repeatedly with A vs B comparisons, this has just broken the visualisations in many of them. Obviously a workaround is hcl.colors(3, "Vik")[c(1, 3)] but this seems rather unintuitive. Thanks in advance, Stevie sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.6 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C time zone: Australia/Adelaide tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 tools_4.3.0 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, I cannot reproduce this on Windows. hcl.colors(2, "Vik") # [1] "#002E60" "#3E2000" clrs <- sapply(hcl.pals(), \(p) hcl.colors(2, p)) any(apply(clrs, 2, \(x) x[1] == x[2])) # [1] FALSE sessionInfo() # R version 4.2.3 (2023-03-15 ucrt) # Platform: x86_64-w64-mingw32/x64 (64-bit) # Running under: Windows 10 x64 (build 22621) # # Matrix products: default # # locale: # [1] LC_COLLATE=Portuguese_Portugal.utf8 LC_CTYPE=Portuguese_Portugal.utf8 # [3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C # [5] LC_TIME=Portuguese_Portugal.utf8 # # attached base packages: # [1] stats graphics grDevices utils datasets methods base # # loaded via a namespace (and not attached): # [1] compiler_4.2.3 Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] grDevices::hcl.colors using two colours: Bug or Feature?
This is a 4.3.0 reversion. I'm seeing it as well on R version 4.3.0 RC (2023-04-13 r84266) Platform: x86_64-apple-darwin20 (64-bit) Running under: macOS Monterey 12.6.5 Duncan Murdoch On 28/04/2023 5:51 a.m., Rui Barradas wrote: Às 06:01 de 28/04/2023, Stevie Pederson escreveu: Hi, I'm not sure if this is a bug or a feature, but after updating to Rv4.3, if requesting two colours from hcl.colors() you now get the same colour twice. This occurs for all palettes I've tried. My reprex: hcl.colors(2, "Vik") [1] "#F1F1F1" "#F1F1F1" As I have multiple workflows I run repeatedly with A vs B comparisons, this has just broken the visualisations in many of them. Obviously a workaround is hcl.colors(3, "Vik")[c(1, 3)] but this seems rather unintuitive. Thanks in advance, Stevie sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.6 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C time zone: Australia/Adelaide tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 tools_4.3.0 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, I cannot reproduce this on Windows. hcl.colors(2, "Vik") # [1] "#002E60" "#3E2000" clrs <- sapply(hcl.pals(), \(p) hcl.colors(2, p)) any(apply(clrs, 2, \(x) x[1] == x[2])) # [1] FALSE sessionInfo() # R version 4.2.3 (2023-03-15 ucrt) # Platform: x86_64-w64-mingw32/x64 (64-bit) # Running under: Windows 10 x64 (build 22621) # # Matrix products: default # # locale: # [1] LC_COLLATE=Portuguese_Portugal.utf8 LC_CTYPE=Portuguese_Portugal.utf8 # [3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C # [5] LC_TIME=Portuguese_Portugal.utf8 # # attached base packages: # [1] stats graphics grDevices utils datasets methods base # # loaded via a namespace (and not attached): # [1] compiler_4.2.3 Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] grDevices::hcl.colors using two colours: Bug or Feature?
Às 06:01 de 28/04/2023, Stevie Pederson escreveu: Hi, I'm not sure if this is a bug or a feature, but after updating to Rv4.3, if requesting two colours from hcl.colors() you now get the same colour twice. This occurs for all palettes I've tried. My reprex: hcl.colors(2, "Vik") [1] "#F1F1F1" "#F1F1F1" As I have multiple workflows I run repeatedly with A vs B comparisons, this has just broken the visualisations in many of them. Obviously a workaround is hcl.colors(3, "Vik")[c(1, 3)] but this seems rather unintuitive. Thanks in advance, Stevie sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.6 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C time zone: Australia/Adelaide tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 tools_4.3.0 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, I cannot reproduce this on Windows. hcl.colors(2, "Vik") # [1] "#002E60" "#3E2000" clrs <- sapply(hcl.pals(), \(p) hcl.colors(2, p)) any(apply(clrs, 2, \(x) x[1] == x[2])) # [1] FALSE sessionInfo() # R version 4.2.3 (2023-03-15 ucrt) # Platform: x86_64-w64-mingw32/x64 (64-bit) # Running under: Windows 10 x64 (build 22621) # # Matrix products: default # # locale: # [1] LC_COLLATE=Portuguese_Portugal.utf8 LC_CTYPE=Portuguese_Portugal.utf8 # [3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C # [5] LC_TIME=Portuguese_Portugal.utf8 # # attached base packages: # [1] stats graphics grDevices utils datasets methods base # # loaded via a namespace (and not attached): # [1] compiler_4.2.3 Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] grDevices::hcl.colors using two colours: Bug or Feature?
Hi, I'm not sure if this is a bug or a feature, but after updating to Rv4.3, if requesting two colours from hcl.colors() you now get the same colour twice. This occurs for all palettes I've tried. My reprex: hcl.colors(2, "Vik") [1] "#F1F1F1" "#F1F1F1" As I have multiple workflows I run repeatedly with A vs B comparisons, this has just broken the visualisations in many of them. Obviously a workaround is hcl.colors(3, "Vik")[c(1, 3)] but this seems rather unintuitive. Thanks in advance, Stevie sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.6 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C time zone: Australia/Adelaide tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.0 tools_4.3.0 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] knitr and tinytex
Here’s what I found: Running the line commands install.packages("knitr") install.packages('tinytex') and interactively in RStudio: Tools->Install Packages -> … both work. Thank you! Steven from iPhone > On Apr 27, 2023, at 8:26 AM, Steven T. Yen wrote: > > Dear tinytex users > > I install knitr and tinytex with the following line commands in RStudio and > it seems to work: > > install.packages("knitr") > install.packages('tinytex') > > In the long past I was told to also run the following lines but now they do > not seem to be needed. > #update.packages(ask = FALSE, checkBuilt = TRUE) > #tinytex::tlmgr_update() > #tinytex::reinstall_tinytex() > > Would running the first two lines above be adequate? Is it also OK run run in > RStudio by Tool -> Install.packages? Thanks you! > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.