Stat.convertDataToROnRjEvolution C# (CSharp) Method

convertDataToROnRjEvolution() private method

private convertDataToROnRjEvolution ( GraphROptions gro, Sides side ) : string
gro GraphROptions
side Sides
return string
    private string convertDataToROnRjEvolution(GraphROptions gro, Sides side)
    {
        string rD = ""; //rDataString
        string bD = "data <- cbind("; //bindDataString
        string colNamesD = "colnames(data) <- c("; //colNamesDataString
        string sepSerie = "";
        int count = 0; //this counts accepted series
        int countSeries = 0; //for RJ
        int countAcceptedCols=0;
        rjEvolutionMaxJumps = -1;
        foreach(GraphSerie serie in GraphSeries) {
            if(
                    side == Sides.LEFT && ! serie.IsLeftAxis ||
                    side == Sides.RIGHT && serie.IsLeftAxis) {
                continue;
            }

            //in isRjEvolution then check if this serie will be shown (each jumper has a TC and a TF serie)
            if(isRjEvolution) {
                if( ! acceptCheckedData( divideAndRoundDown(countSeries)) ) {
                    countSeries ++;
                    continue;
                }
            } else {
                if(! acceptCheckedData(countSeries)) {
                    countSeries ++;
                    continue;
                }
            }

            rD += "serie" + count.ToString() + " <- c(";
            string sep = "";
            countAcceptedCols=0;
            foreach(string val in serie.SerieData) {
                countAcceptedCols++;
                if(val == "-1")
                    rD += sep + "NA"; //don't plot starting -1 on evolutions
                else if(val == "-")
                    rD += sep + "NA"; //don't plot 0's on ended evolutions
                else
                    rD += sep + Util.ConvertToPoint(val);
                sep = ", ";

                if(val != "-" && countAcceptedCols > rjEvolutionMaxJumps)
                    rjEvolutionMaxJumps = countAcceptedCols;
            }
            rD += ")\n";
            bD += sepSerie + "serie" + count.ToString();

            sepSerie = ", ";
            count ++;
            countSeries ++;
        }

        string rowNamesD = "rownames(data) <- c("; //rowNamesDataString

        //create cols
        int i=0;
        string sep2 = "";
        foreach(GraphSerie serie in GraphSeries) {
            if(isRjEvolution) {
                if(acceptCheckedData(divideAndRoundDown(i++))) {
                    colNamesD += sep2 + "'" + serie.Title + "'";
                    sep2 = ", ";
                }
            } else {
                if(acceptCheckedData(i++)) {
                    colNamesD += sep2 + "'" + serie.Title + "'";
                    sep2 = ", ";
                }
            }
        }
        //create rows
        sep2 = "";
        for(int j=1; j < countAcceptedCols+1; j++) {
            rowNamesD += sep2 + j;
            sep2 = ", ";
        }

        bD += ")\n";
        colNamesD += ")\n";
        rowNamesD += ")\n";

        string allData = rD + bD + colNamesD + rowNamesD + "data\n";

        if(gro.Transposed)
            allData += "data <- t(data)\n";

        return allData;
    }