pasting Jpeg output in directory in R
I have function which performs scatter plot and I want to paste the results(Jpeg images) in D:/output but instead it is pasting in D:/.I want my results to be pasted on D:/output. Please do help me.
setwd("D:/output")
IDs <- col开发者_StackOverflow中文版names(raw.expression)
for (i in 1:(dim(raw.expression)[2]-1))
{ for( j in i:(dim(raw.expression)[2]) )
{ if (i != j)
{ jpeg(file=paste("/",IDs[i],"gegen",IDs[j],".jpg",sep=""))
correlation <- round(cor(raw.expression[,i],raw.expression[,j]),2)
maximum <- max(log2(raw.expression[,i]))
minimum <- min(log2(raw.expression[,i]))
plot(log2(raw.expression[,i]),log2(raw.expression[,j])
,xlab=IDs[i],ylab=IDs[j],pch='.'
,text (maximum-2,minimum+0.5
,labels=paste("R = ",correlation,sep=""),pos=4,offset=0))
dev.off()
}
}
}
In the line
jpeg(file=paste("/",IDs[i],"gegen",IDs[j],".jpg",sep=""))
you prepend the filename with a "/" which would indicate that this is an absolute path, starting at the top of the file structure. I'm guessing on windows, this would be the top of the current drive letter, so it is going into D:
rather than the current working directory D:/output
.
精彩评论