Dear list, I have a problem with the "corrgram" function. It does not seem to "color" large negative correlations, while the same correlation, if positive, provides no problems. Is this a bug? require(corrgram) a = seq(1,100) b = -jitter(seq(1,100), 80) cor(a,b) # r about -.96 c=as.data.frame(cbind(a,b)) corrgram(c, order=NULL, lower.panel=panel.pie,upper.panel=NULL, text.panel=panel.txt) # no color c$b = -1*c$b # flip direction of correlation cor(c$a, c$b) # r now about +.96 corrgram(c, order=NULL, lower.panel=panel.pie,upper.panel=NULL, text.panel=panel.txt) #no problem with color. Thanks!
yes it is. and a correlation of 0 isn't exactly white (#FFFFFF) either. have a look at the panel.pie function. the crucial part is ncol <- 14 pal <- col.corrgram(ncol) col.ind <- round(ncol * (corr + 1)/2) so an correlation near -1 maps to an index 0, which isn't a proper index in R. Alter these lines to ncol <- 15 #so 0 becomes "#FFFFFF" pal <- col.corrgram(ncol) col.ind <- round((ncol-1) * (corr + 1)/2)+1 hth. Am 28.06.2011 13:11, schrieb Niels Janssen:> Dear list, > > I have a problem with the "corrgram" function. It does not seem to > "color" large negative correlations, while the same correlation, if > positive, provides no problems. Is this a bug? > > require(corrgram) > a = seq(1,100) > b = -jitter(seq(1,100), 80) > cor(a,b) # r about -.96 > c=as.data.frame(cbind(a,b)) > corrgram(c, order=NULL, lower.panel=panel.pie,upper.panel=NULL, > text.panel=panel.txt) # no color > > c$b = -1*c$b # flip direction of correlation > cor(c$a, c$b) # r now about +.96 > corrgram(c, order=NULL, lower.panel=panel.pie,upper.panel=NULL, > text.panel=panel.txt) #no problem with color. > > Thanks! > > ______________________________________________ > R-help at r-project.org mailing list > 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.-- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790
This bug has been fixed. Kevin On Tue, Jun 28, 2011 at 6:11 AM, Niels Janssen <njanssen@ull.es> wrote:> Dear list, > > I have a problem with the "corrgram" function. It does not seem to "color" > large negative correlations, while the same correlation, if positive, > provides no problems. Is this a bug? > > require(corrgram) > a = seq(1,100) > b = -jitter(seq(1,100), 80) > cor(a,b) # r about -.96 > c=as.data.frame(cbind(a,b)) > corrgram(c, order=NULL, lower.panel=panel.pie,upper.**panel=NULL, > text.panel=panel.txt) # no color > > c$b = -1*c$b # flip direction of correlation > cor(c$a, c$b) # r now about +.96 > corrgram(c, order=NULL, lower.panel=panel.pie,upper.**panel=NULL, > text.panel=panel.txt) #no problem with color. > > Thanks! > > ______________________________**________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide http://www.R-project.org/** > posting-guide.html <http://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]