private string getRXYString(GraphROptions gro, string fileName)
{
string allData = convertDataToR(gro, Sides.ALL);
string titStr = getTitle(Catalog.GetString("Dispersion"), "sub=paste('correlation:',cor(serie0,serie1),' R^2:',cor(serie0,serie1)^2)");
string colors="colors";
bool changedPalette = false;
if(gro.Palette == Constants.GraphPaletteBlack) {
colors="'black'";
gro.Palette="gray.colors";
changedPalette = true;
}
//prediction is discussed here:
//https://stat.ethz.ch/pipermail/r-help-es/2009-December/000539.html
string rG = //rGraphString
"colors=" + gro.Palette +"(length(rownames(data)))\n" +
"rang <- c(1:length(rownames(data)))\n" +
//"plot(serie0, serie1, pch=rang, col="+ colors +", xlab='" + Util.RemoveTilde(gro.VarX) + "', ylab='" + Util.RemoveTilde(gro.VarY) + "')\n" +
"plot(serie0,serie1,xlim=c(min(serie0),max(serie0)),ylim=c(min(serie1),max(serie1)), " +
"pch=rang, lwd="+ gro.LineWidth +", col="+ colors +", xlab='" + Util.RemoveTilde(gro.VarX) +
"', ylab='" + Util.RemoveTilde(gro.VarY) + "')\n" +
"legend('" + gro.Legend +"' ,legend=rownames(data), pch=rang, col="+ colors +", cex=.7)\n" +
titStr + "\n" +
"mylm<-lm(serie1~serie0)\n" +
"abline(mylm,col='red', lwd="+ gro.LineWidth +")\n" +
"newx<-seq(min(serie0),max(serie0),length.out=length(serie0))\n" +
"prd<-predict(mylm,newdata=data.frame(serie0=newx),interval = c('confidence'), level = 0.90,type='response')\n" +
"lines(newx,prd[,3],col='red', lwd="+ gro.LineWidth +",lty=2)\n" +
"lines(newx,prd[,2],col='red', lwd="+ gro.LineWidth +",lty=2)\n" +
"text(newx[1],prd[1,3],'90%', cex=0.6)\n" +
"text(newx[1],prd[1,2],'90%', cex=0.6)\n" +
"text(newx[length(newx)],prd[length(newx),3],'90%', cex=0.6)\n" +
"text(newx[length(newx)],prd[length(newx),2],'90%', cex=0.6)\n";
if(changedPalette)
gro.Palette=Constants.GraphPaletteBlack;
return allData + rG;
}