2014-03-26 85 views
1

我写了这个代码{Hmisc} x轴:情节errbar当x因子R

with (data = puresa, 
     expr = errbar(Chr, Purity, Purity+sd, Purity-sd, add=F, pch=1, cap=.015)) 

它绘制这样一个情节:

enter image description here

但我的目标是绘制Chr在xlab中,而不是在ylab中,就像上面的plot一样。问题在于“Chr”是一个因素。因为当我打印出来的数字我得到我的目标:

with (data = puresa, 
     expr = errbar(as.numeric(Chr), Purity, Purity+sd, Purity-sd, cap=.015)) 

enter image description here

利用这最后的情节的问题是,我不能与人权委员会的名称替换xlab值。

我想这个代码,但它是不工作...

with (data = puresa, 
     expr = errbar(as.numeric(Chr), Purity, Purity+sd, Purity-sd, 
        xlab=if(is.character(Chr) || is.character(Chr)) "" else (substitute(Chr)))) 

enter image description here

我会apreciate您的帮助,非常感谢你!

回答

2

好,我做到了!

par(las=2) 
plot(as.numeric(puresa$Chr), puresa$Purity, type="n", xaxt = "n", ylim=c(0,1), main="Tumor purity", xlab="Chromosome", ylab="Purity") 
errbar(as.numeric(puresa$Chr), puresa$Purity, puresa$Purity+puresa$sd, puresa$Purity-puresa$sd, add=T) 
axis(1, at=1:25, labels=levels(puresa$Chr), cex.axis=0.8) 

enter image description here

希望它可以帮助别人。