R语言 eval parse 字符串内有引号 格式化输出
生活随笔
收集整理的這篇文章主要介紹了
R语言 eval parse 字符串内有引号 格式化输出
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
字符串中添加引號時,要用 \ 轉義
’ 輸出為’
在eval表達式中存在引號,要轉義
格式化輸出
sprintf("%03d",i) # 前面補0
R語言 colormap設置
palette(rainbow(N))
list是個非常有用的數據結構,畫圖的時候會異常方便。
sto=array(NA,c(96,length(var_name_sto),3,2),dimnames=list(1:96,var_name_sto,expe,c("RS","noRS")))for (v in var_name_sto){for (ex in expe) {for (i in 1:2) {ev_text=paste("tmp=month_",var_flag[i],ex,"_",v,sep="")eval(parse(text=ev_text))sto[,v,ex,i]=tmp[,1]}}}colex=c(1,2,"forestgreen") liflag=c(1,2)# OVERviewpdf(paste0(figpath,"sto_ov.pdf"),4,8) par(mfcol=c(6,1)) par(mar=c(2,3,3,3)) for (v in var_name_sto){plot(sto[,v,1,1],type="l",col="white",las=1,main=v,ylim=range(sto[,v,1:2,]),xaxt="n",xlab="",ylab="")axis(1,at=seq(1,by=12,length.out=10),labels=seq(2001,by=1,length.out=10))grid()for (ex in 1:2){for (i in 1:2) lines(sto[,v,ex,i],col=colex[ex],lty=liflag[i],lwd=2)} }legend("bottomleft",legend=expe[1:2],text.col=colex[1:2],bty="n",cex=1)legend("bottom",legend=c("RS","noRS"),text.col=1,lty=liflag,bty="n",cex=1) dev.off()總結
以上是生活随笔為你收集整理的R语言 eval parse 字符串内有引号 格式化输出的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C. Dominant Piranha(
- 下一篇: 基于video.js 的在线播放功能