R--随处收藏

2018-08-02-临时替换R包函数相关片段

2018-08-02  本文已影响0人  zouxiaoyu

今天突然知道eval和gsub等函数可以直接说上来用。很开心。。学无止境。。其实每次学到新东西才是最快乐的不是。

https://stackoverflow.com/questions/12925213/prevent-cex-from-scaling-with-the-correlation-coefficient-in-chart-correlation

library("PerformanceAnalytics") ## turn the function into a character 

stringtmpstr <- deparse(chart.Correlation) ## modify the relevant linespanelcorline <- grep("^ *panel.cor",tmpstr)

tmpstr[panelcorline] <-paste(tmpstr[panelcorline],"cex.cor.scale=1,")

rscaleline <- grep("^ *text\\(0.5",tmpstr)

## convert back to a function (don't mask the original function)

tmpstr[rscaleline] <- gsub("cex \\* r","cex*r^cex.cor.scale",tmpstr[rscaleline]) 

my.chart.Correlation <- eval(parse(text=tmpstr))

上一篇下一篇

猜你喜欢

热点阅读