PerformanceAnalytics
PerformanceAnalytics copied to clipboard
chart.Correlation - Point shapes won't change with `pch`
Hi, we can't change the point shapes wit the pch
.
Reproducible example:
library("PerformanceAnalytics")
chart.Correlation(iris[1:4], histogram=TRUE, pch = "+")
We can't see any +
in the plot. Thanks for looking into this.
See below for a version that supports pch
and other plot options. I added ...
to the two pairs
calls.
chart.Correlation <- function (R, histogram = TRUE, method = c("pearson", "kendall",
"spearman"), ...)
{
x = checkData(R, method = "matrix")
if (missing(method))
method = method[1]
panel.cor <- function(x, y, digits = 2, prefix = "", use = "pairwise.complete.obs",
method = "pearson", cex.cor, ...) {
usr <- par("usr")
on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- cor(x, y, use = use, method = method)
txt <- format(c(r, 0.123456789), digits = digits)[1]
txt <- paste(prefix, txt, sep = "")
if (missing(cex.cor))
cex <- 0.8/strwidth(txt)
test <- cor.test(as.numeric(x), as.numeric(y), method = method)
Signif <- symnum(test$p.value, corr = FALSE, na = FALSE,
cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1), symbols = c("***",
"**", "*", ".", " "))
text(0.5, 0.5, txt, cex = cex * (abs(r) + 0.3)/1.3)
text(0.8, 0.8, Signif, cex = cex, col = 2)
}
f <- function(t) {
dnorm(t, mean = mean(x), sd = sd.xts(x))
}
dotargs <- list(...)
dotargs$method <- NULL
rm(method)
hist.panel = function(x, ... = NULL) {
par(new = TRUE)
hist(x, col = "light gray", probability = TRUE, axes = FALSE,
main = "", breaks = "FD")
lines(density(x, na.rm = TRUE), col = "red", lwd = 1)
rug(x)
}
if (histogram)
pairs(x, gap = 0, lower.panel = panel.smooth, upper.panel = panel.cor,
diag.panel = hist.panel, ...)
else pairs(x, gap = 0, lower.panel = panel.smooth, upper.panel = panel.cor, ...)
}
There is no sessionInfo here, but I'll assume from the context that this pertains to the latest PerformanceAnalytics that was just released to CRAN last week.
Those dots were removed specifically to deal with warnings generated by r-devel ahead of the CRAN release. So any change will need to not incur those warnings.
Any news on this one? If it can not be fixed, then at least remove the "..." argument from the documentation so people are not led astray.
Thanks @DavorJ for the reminder, apologies this escaped my attention in the hustle. +
wont appear with PerformanceAnalytics 1.5.2. However @Mako21 's update on Mar 6, 2018 above is working fine for me. Below is a session info. Cheers!
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] PerformanceAnalytics_1.5.2 xts_0.11-2
[3] zoo_1.8-4
loaded via a namespace (and not attached):
[1] compiler_3.5.2 tools_3.5.2 yaml_2.2.0 grid_3.5.2
[5] lattice_0.20-38 quadprog_1.5-5
@peterccarl can you take a quick look at this and maybe apply?
Hi
I have the same problem
reproducible example :
chart.Correlation(iris[-5], bg=iris$Species, pch=21)
pch remains = 1 regardless of the value used
bg has no effect since pch must be between 21 and 25
col has no effect
Two year ago it worked very well Example I just found that works : https://www.r-bloggers.com/graphically-analyzing-variable-interactions-in-r/
This problem is blocking for me. It's terrible that something no longer works.
Thanks in advance
R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] GGally_1.4.0 ggplot2_3.2.1 PerformanceAnalytics_1.5.3 xts_0.11-2
[5] zoo_1.8-6
loaded via a namespace (and not attached):
[1] Rcpp_1.0.3 magrittr_1.5 hms_0.5.2 progress_1.2.2 munsell_0.5.0
[6] colorspace_1.4-1 lattice_0.20-38 R6_2.4.1 rlang_0.4.2 quadprog_1.5-8
[11] stringr_1.4.0 plyr_1.8.5 tools_3.6.2 grid_3.6.2 gtable_0.3.0
[16] withr_2.1.2 assertthat_0.2.1 lazyeval_0.2.2 tibble_2.1.3 lifecycle_0.1.0
[21] crayon_1.3.4 farver_2.0.1 reshape2_1.4.3 RColorBrewer_1.1-2 vctrs_0.2.0
[26] zeallot_0.1.0 labeling_0.3 stringi_1.4.3 compiler_3.6.2 pillar_1.4.2
[31] prettyunits_1.0.2 scales_1.1.0 backports_1.1.5 reshape_0.8.8 pkgconfig_2.0.3
Hi is there any solutions to that same small font problem? I am having that same problem. Here is my sessioninfo:
sessionInfo() R version 4.0.3 (2020-10-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] PerformanceAnalytics_2.0.4 xts_0.12.1
[3] zoo_1.8-8 pvclust_2.2-0
[5] vegan_2.5-7 lattice_0.20-41
[7] permute_0.9-5
loaded via a namespace (and not attached):
[1] knitr_1.31 cluster_2.1.0 splines_4.0.3 MASS_7.3-53
[5] rlang_0.4.10 quadprog_1.5-8 tcltk_4.0.3 tools_4.0.3
[9] parallel_4.0.3 grid_4.0.3 nlme_3.1-152 mgcv_1.8-33
[13] xfun_0.20 htmltools_0.5.1 yaml_2.2.1 digest_0.6.27
[17] bookdown_0.21 Matrix_1.2-18 evaluate_0.14 rmarkdown_2.6
[21] compiler_4.0.3