//comes from report.cs public StatType(string statisticType, string statisticSubType, string statisticApplyTo, ArrayList sendSelectedSessions, bool sex_active, int statsJumpsType, int limit, ArrayList markedRows, int evolution_mark_consecutives, GraphROptions gRO, bool graph, bool toReport, Preferences preferences, TextWriter writer, string fileName, int statCount ) { this.statisticType = statisticType; this.statisticSubType = statisticSubType; this.statisticApplyTo = statisticApplyTo; this.markedRows = markedRows; this.evolution_mark_consecutives = evolution_mark_consecutives; this.graph = graph; this.toReport = toReport; this.writer = writer; this.fileName = fileName; this.statCount = statCount; myStatTypeStruct = new StatTypeStruct( statisticApplyTo, sendSelectedSessions, sex_active, statsJumpsType, limit, markedRows, gRO, toReport, preferences); myStat = new Stat(); //create and instance of myStat }
//comes from gui/stats.cs public StatType(string statisticType, string statisticSubType, string statisticApplyTo, Gtk.TreeView treeview_stats, ArrayList sendSelectedSessions, bool sex_active, int statsJumpsType, int limit, ArrayList markedRows, int evolution_mark_consecutives, GraphROptions gRO, bool graph, bool toReport, Preferences preferences) { //some of this will disappear when we use myStatTypeStruct in all classes: this.statisticType = statisticType; this.statisticSubType = statisticSubType; this.statisticApplyTo = statisticApplyTo; this.treeview_stats = treeview_stats; this.markedRows = markedRows; this.evolution_mark_consecutives = evolution_mark_consecutives; this.graph = graph; this.toReport = toReport; myStatTypeStruct = new StatTypeStruct( statisticApplyTo, sendSelectedSessions, sex_active, statsJumpsType, limit, markedRows, gRO, toReport, preferences); myStat = new Stat(); //create an instance of myStat fakeButtonRowCheckedUnchecked = new Gtk.Button(); fakeButtonRowsSelected = new Gtk.Button(); fakeButtonNoRowsSelected = new Gtk.Button(); }
//comes from gui/stats.cs public StatType(string statisticType, string statisticSubType, string statisticApplyTo, Gtk.TreeView treeview_stats, ArrayList sendSelectedSessions, bool sex_active, int statsJumpsType, int limit, ArrayList markedRows, int evolution_mark_consecutives, GraphROptions gRO, bool graph, bool toReport, Preferences preferences) { //some of this will disappear when we use myStatTypeStruct in all classes: this.statisticType = statisticType; this.statisticSubType = statisticSubType; this.statisticApplyTo = statisticApplyTo; this.treeview_stats = treeview_stats ; this.markedRows = markedRows; this.evolution_mark_consecutives = evolution_mark_consecutives; this.graph = graph; this.toReport = toReport; myStatTypeStruct = new StatTypeStruct ( statisticApplyTo, sendSelectedSessions, sex_active, statsJumpsType, limit, markedRows, gRO, toReport, preferences); myStat = new Stat(); //create an instance of myStat fakeButtonRowCheckedUnchecked = new Gtk.Button(); fakeButtonRowsSelected = new Gtk.Button(); fakeButtonNoRowsSelected = new Gtk.Button(); }
private void on_button_graph_clicked(object o, EventArgs args) { if (selected) { TreeModel model; TreeIter iter1; if (treeview1.Selection.GetSelected(out model, out iter1)) { string str = getRow(iter1); string [] statRow = str.ToString().Split(new char[] { '\t' }); string subType; int rj_evolution_mark_consecutives = report.GetRjEvolutionMarkConsecutives(statRow[1], out subType); ArrayList sendSelectedSessions = report.GetSelectedSessions(statRow[3]); Gtk.TreeView treeviewFake = new Gtk.TreeView(); //not needed for graph bool showSex = Util.StringToBool(statRow[5]); int limit = -1; int statsJumpsType = report.GetStatsJumpTypeAndLimit(statRow[4], out limit); ArrayList arrayListMarkedRows = Util.StringToArrayList(statRow[6], ':'); GraphROptions graphROptions = new GraphROptions(statRow[7]); StatType myStatType = new StatType( statRow[0], //statisticType subType, statRow[2], //statisticApplyTo, treeviewFake, sendSelectedSessions, showSex, statsJumpsType, limit, arrayListMarkedRows, rj_evolution_mark_consecutives, graphROptions, true, //graph false, //always false in this class report.preferences ); myStatType.ChooseStat(); } } }
public StatTypeStruct(string statisticApplyTo, ArrayList sendSelectedSessions, bool sex_active, int statsJumpsType, int limit, ArrayList markedRows, GraphROptions gRO, bool toReport, Preferences preferences) { this.StatisticApplyTo = statisticApplyTo; this.SendSelectedSessions = sendSelectedSessions; this.Sex_active = sex_active; this.StatsJumpsType = statsJumpsType; this.Limit = limit; this.MarkedRows = markedRows; this.GRO = gRO; this.ToReport = toReport; this.preferences = preferences; }
//comes from stats window public void Add(string type, string subtype, string applyTo, ArrayList sendSelectedSessions, string showJumps, string showSex, ArrayList markedRows, GraphROptions gro) { string sessionsAsAString = arrayToString(sendSelectedSessions); string markedRowsAsAString = arrayToString(markedRows); store.AppendValues( type, subtype, applyTo, sessionsAsAString, showJumps, showSex, markedRowsAsAString, gro.ToString(), "" //comment ); //show report window if it's not shown report_window.Show(); }
protected void completeConstruction(StatTypeStruct myStatTypeStruct, Gtk.TreeView treeview) { //TODO: check, this is weird... this.sessions = myStatTypeStruct.SendSelectedSessions; pDN = myStatTypeStruct.preferences.digitsNumber; this.showSex = myStatTypeStruct.Sex_active; this.statsJumpsType = myStatTypeStruct.StatsJumpsType; this.heightPreferred = myStatTypeStruct.preferences.heightPreferred; this.weightStatsPercent = myStatTypeStruct.preferences.weightStatsPercent; this.statsJumpsType = myStatTypeStruct.StatsJumpsType; this.limit = myStatTypeStruct.Limit; this.jumpType = myStatTypeStruct.StatisticApplyTo; this.markedRows = myStatTypeStruct.MarkedRows; this.gRO = myStatTypeStruct.GRO; this.toReport = myStatTypeStruct.ToReport; this.graphTranslate = myStatTypeStruct.preferences.RGraphsTranslate; this.useHeightsOnJumpIndexes = myStatTypeStruct.preferences.useHeightsOnJumpIndexes; this.treeview = treeview; //initialize reportString reportString = ""; iter = new TreeIter(); personsWithData = new ArrayList(); }
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; }
private string getRStripchartString(GraphROptions gro, string fileName, Sides side) { string allData = convertDataToR(gro, side); string xlabStr = ""; if(side == Sides.RIGHT) { if(CurrentGraphData.LabelRight != "") xlabStr = ", xlab='" + Util.RemoveTilde(CurrentGraphData.LabelRight) + "'"; } else { //ALL or LEFT if(CurrentGraphData.LabelLeft != "") xlabStr = ", xlab='" + Util.RemoveTilde(CurrentGraphData.LabelLeft) + "'"; } string rG = //rGraphString "stripchart(as.data.frame(data), lwd="+ gro.LineWidth +", las=2" + xlabStr + ", ylab='', method='jitter', pch=3, jitter=.2)\n" + "axis(2, 1:length(colnames(data)), colnames(data), las=2)\n"; //axis separated from boxplot because if data hsa one col, names are not displayed //have an unique title for both graphs string titStr = getTitle("Stripchart",""); if(hasTwoAxis()) { if(side==Sides.RIGHT) rG += "par(mfrow=c(1,1), new=TRUE)\n" + "plot(-1, axes=FALSE, type='n', xlab='', ylab='')\n" + titStr + "par(mfrow=c(1,1), new=FALSE)\n"; } else rG += titStr; return allData + rG; }
private string getRLinesString(GraphROptions gro, string fileName, Sides side) { string allData = ""; if(isRjEvolution || isRunIntervalEvolution) allData = convertDataToROnRjEvolution(gro, side); else allData = convertDataToR(gro, side); string axesStr = ""; string ylabStr = ""; if(side == Sides.RIGHT) { axesStr = " axis(4)\n"; if(CurrentGraphData.LabelRight != "") ylabStr = ", ylab='" + Util.RemoveTilde(CurrentGraphData.LabelRight) + "'"; } else { //ALL or LEFT axesStr = " axis(2)\n"; if(CurrentGraphData.LabelLeft != "") ylabStr = ", ylab='" + Util.RemoveTilde(CurrentGraphData.LabelLeft) + "'"; } string naString = ", na.rm = TRUE"; string xlimString = "c(0,length(colnames(data))+1)"; if(isRjEvolution || isRunIntervalEvolution) xlimString = "c(1," + rjEvolutionMaxJumps + ")"; //TC and TF same color on rjEvo string colorsConversionString = ""; string colors1="colors[1]"; string colorsi="colors[i]"; string colors="colors"; bool changedPalette = false; if(gro.Palette == Constants.GraphPaletteBlack) { colors1="'black'"; colorsi="'black'"; colors="'black'"; gro.Palette="gray.colors"; changedPalette = true; } else if(isRjEvolution) //runIntervalEvolution doesn't have this because only has one serie colorsConversionString = "for(i in 2:length(colors)) if(i%%2 == 0) colors[i]=colors[i-1]\n"; string rG = //rGraphString " colors=" + gro.Palette +"(length(rownames(data)))\n" + colorsConversionString + " plot(data[1,1:length(colnames(data))], type='b', lwd="+ gro.LineWidth +", xlim=" + xlimString + "," + " ylim=c(min(data" + naString +"),max(data" + naString + ")), pch=1, axes=FALSE, col="+ colors1 +", xlab=''" + ylabStr + ")\n" + " if(length(rownames(data))>=2) {\n" + " for(i in 2:length(rownames(data)))\n" + " points(data[i,1:length(colnames(data))], type='b', lwd="+ gro.LineWidth +", pch=i, col="+ colorsi +")\n" + " }\n" + " axis(1, 1:length(colnames(data)), colnames(data), las=2)\n" + axesStr + " legend('" + gro.Legend +"', legend=rownames(data), pch=c(1:length(rownames(data))), cex=.7, col="+ colors +")\n"; if(changedPalette) gro.Palette=Constants.GraphPaletteBlack; //have an unique title for both graphs string titStr = getTitle("Lines", ""); if(hasTwoAxis()) { if(side==Sides.RIGHT) rG += "par(mfrow=c(1,1), new=TRUE)\n" + "plot(-1, axes=FALSE, type='n', xlab='', ylab='')\n" + titStr + "par(mfrow=c(1,1), new=FALSE)\n"; } else rG += titStr; return allData + rG; }
private string convertDataToR(GraphROptions gro, Sides side) { string rD = ""; //rDataString string bD = "data <- cbind("; //bindDataString string colNamesD = "colnames(data) <- c("; //colNamesDataString string sepSerie = ""; string xyFirstFound = ""; int count = 0; //this counts accepted series int countCols=0; foreach(GraphSerie serie in GraphSeries) { if( side == Sides.LEFT && ! serie.IsLeftAxis || side == Sides.RIGHT && serie.IsLeftAxis) { continue; } //don't plot AVG row on multisession if(sessions.Count > 1 && serie.Title == Catalog.GetString("AVG")) continue; //on XY only take two vars if(gro.Type == Constants.GraphTypeXY) { Log.WriteLine("groVarX: " + gro.VarX + " groVarY: " + gro.VarY + " tit: " + serie.Title); if(gro.VarX != serie.Title && gro.VarY != serie.Title) continue; else if (xyFirstFound == "") { if(gro.VarX == serie.Title) xyFirstFound = "x"; else xyFirstFound = "y"; } } //Histogram and Dotchart plot col 1 if( (gro.Type == Constants.GraphTypeHistogram || gro.Type == Constants.GraphTypeDotchart) && gro.VarX != serie.Title) continue; rD += "serie" + count.ToString() + " <- c("; string sep = ""; countCols=0; foreach(string val in serie.SerieData) { bool use = true; if(! acceptCheckedData(countCols)) use = false; //don't plot AVG col on multisession if(sessions.Count > 1 && countCols == serie.SerieData.Count) use = false; //don't plot SD col on multisession if(sessions.Count > 1 && countCols +1 == serie.SerieData.Count) use = false; countCols++; if(! use) continue; if(val == "-") rD += sep + "NA"; else rD += sep + Util.ConvertToPoint(val); sep = ", "; } rD += ")\n"; bD += sepSerie + "serie" + count.ToString(); colNamesD += sepSerie + "'" + Util.RemoveTilde(serie.Title) + "'"; sepSerie = ", "; count ++; } string rowNamesD = "rownames(data) <- c("; //rowNamesDataString //create rows string sep2 = ""; for(int i=0; i < CurrentGraphData.XAxisNames.Count; i++) { if(! acceptCheckedData(i)) continue; rowNamesD += sep2 + "'" + Util.RemoveTilde(CurrentGraphData.XAxisNames[i].ToString()) + "'"; sep2 = ", "; } bD += ")\n"; colNamesD += ")\n"; rowNamesD += ")\n"; if(gro.Type == Constants.GraphTypeXY) { if(gro.VarX == gro.VarY) { //if it's an XY with only one serie, (both selected vars are the same rD += rD.Replace("serie0", "serie1"); //duplicate rD changing serie name bD = "data <- cbind(serie0, serie1)\n"; //have two colNamesD equal to first string [] cn = colNamesD.Split(new char[] {'\''}); colNamesD = "colnames(data) <- c('" + cn[1] + "', '" + cn[1] + "')\n"; } else if (xyFirstFound == "y") { //if we first found the y value change serie0 to serie1 rD = rD.Replace("serie1", "serie2"); rD = rD.Replace("serie0", "serie1"); rD = rD.Replace("serie2", "serie0"); } } string allData = rD + bD + colNamesD + rowNamesD + "data\n"; if(gro.Transposed && gro.Type != Constants.GraphTypeXY && gro.Type != Constants.GraphTypeDotchart && gro.Type != Constants.GraphTypeBoxplot && gro.Type != Constants.GraphTypeHistogram && gro.Type != Constants.GraphTypeStripchart ) allData += "data <- t(data)\n"; return allData; }
protected void printStats() { if (StatisticsData.Count > 0) { writer.WriteLine("<h2>Statistics</h2>"); } //obtain every report stats one by one for (int statCount = 0; statCount < StatisticsData.Count; statCount++) { string [] strFull = StatisticsData[statCount].ToString().Split(new char[] { '\t' }); string myHeaderStat = ""; //separate in sessions ArrayList sendSelectedSessions = GetSelectedSessions(strFull[3]); //separate in markedRows ArrayList arrayListMarkedRows = Util.StringToArrayList(strFull[6], ':'); string applyTo = strFull[2]; myHeaderStat += "<h3> " + strFull[0] + " : " + strFull[1] + " : " + applyTo + "</h3> "; bool showSex = Util.StringToBool(strFull[5]); int limit; int statsJumpsType = GetStatsJumpTypeAndLimit(strFull[4], out limit); //obtain marked jumps of rj evolution if needed string subType; int rj_evolution_mark_consecutives = GetRjEvolutionMarkConsecutives(strFull[1], out subType); myHeaderStat += "\n<p><TABLE cellpadding=2 cellspacing=2><tr><td>\n"; writer.WriteLine(myHeaderStat); StatType myStatType; //bool allFine; //report of stat GraphROptions graphROptions = new GraphROptions(strFull[7]); myStatType = new StatType( strFull[0], //statisticType subType, //statisticSubType strFull[2], //statisticApplyTo sendSelectedSessions, showSex, statsJumpsType, limit, arrayListMarkedRows, rj_evolution_mark_consecutives, graphROptions, false, //graph toReport, preferences, writer, "", statCount ); //allFine = myStatType.ChooseStat(); myStatType.ChooseStat(); string myEnunciate = "<tr><td>" + myStatType.Enunciate + "</td></tr>"; writer.WriteLine("<br>"); //report of graph myStatType = new StatType( strFull[0], //statisticType subType, //statisticSubType strFull[2], //statisticApplyTo sendSelectedSessions, showSex, statsJumpsType, limit, arrayListMarkedRows, rj_evolution_mark_consecutives, graphROptions, true, //graph toReport, preferences, writer, fileName, //fileName for exporting there statCount ); myStatType.ChooseStat(); //enunciate is prented here and not before //because myStatType of a graph doesn't know the numContinuous value //needed for enunciate in rj evolution statistic writer.WriteLine(myEnunciate); writer.WriteLine("<tr><td>" + strFull[8] + "</td></tr>"); //comment writer.WriteLine("</table>"); } }
private void on_button_graph_clicked(object o, EventArgs args) { if(selected) { TreeModel model; TreeIter iter1; if (treeview1.Selection.GetSelected (out model, out iter1)) { string str=getRow(iter1); string [] statRow = str.ToString().Split(new char[] {'\t'}); string subType; int rj_evolution_mark_consecutives = report.GetRjEvolutionMarkConsecutives(statRow[1], out subType); ArrayList sendSelectedSessions = report.GetSelectedSessions(statRow[3]); Gtk.TreeView treeviewFake = new Gtk.TreeView(); //not needed for graph bool showSex = Util.StringToBool(statRow[5]); int limit = -1; int statsJumpsType = report.GetStatsJumpTypeAndLimit(statRow[4], out limit); ArrayList arrayListMarkedRows = Util.StringToArrayList(statRow[6], ':'); GraphROptions graphROptions = new GraphROptions(statRow[7]); StatType myStatType = new StatType( statRow[0], //statisticType subType, statRow[2], //statisticApplyTo, treeviewFake, sendSelectedSessions, showSex, statsJumpsType, limit, arrayListMarkedRows, rj_evolution_mark_consecutives, graphROptions, true, //graph false, //always false in this class report.preferences ); myStatType.ChooseStat(); } } }
//comes from stats window public void Add(string type, string subtype, string applyTo, ArrayList sendSelectedSessions, string showJumps, string showSex, ArrayList markedRows, GraphROptions gro) { string sessionsAsAString = arrayToString(sendSelectedSessions); string markedRowsAsAString = arrayToString(markedRows); store.AppendValues ( type, subtype, applyTo, sessionsAsAString, showJumps, showSex, markedRowsAsAString, gro.ToString(), "" //comment ); //show report window if it's not shown report_window.Show (); }
private string convertDataToR(GraphROptions gro, Sides side) { string rD = ""; //rDataString string bD = "data <- cbind("; //bindDataString string colNamesD = "colnames(data) <- c("; //colNamesDataString string sepSerie = ""; string xyFirstFound = ""; int count = 0; //this counts accepted series int countCols=0; int countRows=0; //on multisession, names of persons come in rows. Use this to discard some rows if unselected on treeview (! markedRows) foreach(GraphSerie serie in GraphSeries) { LogB.Information("serie:" + serie.Title); if( side == Sides.LEFT && ! serie.IsLeftAxis || side == Sides.RIGHT && serie.IsLeftAxis) { continue; } //don't plot AVG row on multisession if(sessions.Count > 1 && serie.Title == Catalog.GetString("AVG")) continue; //on multisession, names of persons come in rows. Use this to discard some rows if unselected on treeview (! markedRows) if(sessions.Count > 1 && ! acceptCheckedData(countRows)) { countRows ++; continue; } //on XY only take two vars if(gro.Type == Constants.GraphTypeXY) { LogB.Information("groVarX: " + gro.VarX + " groVarY: " + gro.VarY + " tit: " + serie.Title); if(gro.VarX != serie.Title && gro.VarY != serie.Title) continue; else if (xyFirstFound == "") { if(gro.VarX == serie.Title) xyFirstFound = "x"; else xyFirstFound = "y"; } } //Histogram and Dotchart plot col 1 if( (gro.Type == Constants.GraphTypeHistogram || gro.Type == Constants.GraphTypeDotchart) && gro.VarX != serie.Title) continue; rD += "serie" + count.ToString() + " <- c("; string sep = ""; countCols=0; foreach(string val in serie.SerieData) { LogB.Information(" val:" + val); bool use = true; //on simplesession, cols are persons. See if they are discarded on markedRows if(sessions.Count == 1 && ! acceptCheckedData(countCols)) use = false; //don't plot AVG col on multisession if(sessions.Count > 1 && countCols == serie.SerieData.Count) use = false; //don't plot SD col on multisession if(sessions.Count > 1 && countCols +1 == serie.SerieData.Count) use = false; countCols++; if(! use) continue; if(val == "-") rD += sep + "NA"; else rD += sep + Util.ConvertToPoint(val); sep = ", "; } rD += ")\n"; bD += sepSerie + "serie" + count.ToString(); colNamesD += sepSerie + "'" + Util.RemoveTilde(serie.Title) + "'"; sepSerie = ", "; count ++; countRows ++; } string rowNamesD = "rownames(data) <- c("; //rowNamesDataString //create rows string sep2 = ""; for(int i=0; i < CurrentGraphData.XAxisNames.Count; i++) { //on simplesession, cols are persons. See if they are discarded on markedRows if(sessions.Count == 1 && ! acceptCheckedData(i)) continue; string name = Util.RemoveTilde(CurrentGraphData.XAxisNames[i].ToString()); //convert accents to Unicode in order to be plotted correctly on R windows if(UtilAll.IsWindows()) name = Util.ConvertToUnicode(name); rowNamesD += sep2 + "'" + name + "'"; //each four values add a \n to not have a "long line" problem in sending data to R if((i+1) % 4 == 0) rowNamesD += "\n"; sep2 = ", "; } bD += ")\n"; colNamesD += ")\n"; rowNamesD += ")\n"; if(gro.Type == Constants.GraphTypeXY) { if(gro.VarX == gro.VarY) { //if it's an XY with only one serie, (both selected vars are the same rD += rD.Replace("serie0", "serie1"); //duplicate rD changing serie name bD = "data <- cbind(serie0, serie1)\n"; //have two colNamesD equal to first string [] cn = colNamesD.Split(new char[] {'\''}); colNamesD = "colnames(data) <- c('" + cn[1] + "', '" + cn[1] + "')\n"; } else if (xyFirstFound == "y") { //if we first found the y value change serie0 to serie1 rD = rD.Replace("serie1", "serie2"); rD = rD.Replace("serie0", "serie1"); rD = rD.Replace("serie2", "serie0"); } } string allData = rD + bD + colNamesD + rowNamesD + "data\n"; if(gro.Transposed && gro.Type != Constants.GraphTypeXY && gro.Type != Constants.GraphTypeDotchart && gro.Type != Constants.GraphTypeBoxplot && gro.Type != Constants.GraphTypeHistogram && gro.Type != Constants.GraphTypeStripchart ) allData += "data <- t(data)\n"; return allData; }
public StatTypeStruct(string statisticApplyTo, ArrayList sendSelectedSessions, int prefsDigitsNumber, bool sex_active, int statsJumpsType, int limit, bool heightPreferred, bool weightStatsPercent, ArrayList markedRows, GraphROptions gRO, bool toReport) { this.StatisticApplyTo = statisticApplyTo; this.SendSelectedSessions = sendSelectedSessions; this.PrefsDigitsNumber = prefsDigitsNumber; this.Sex_active = sex_active; this.StatsJumpsType = statsJumpsType; this.Limit = limit; this.HeightPreferred = heightPreferred; this.WeightStatsPercent = weightStatsPercent; this.MarkedRows = markedRows; this.GRO = gRO; this.ToReport = toReport; }
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; }
//comes from report.cs public StatType(string statisticType, string statisticSubType, string statisticApplyTo, ArrayList sendSelectedSessions, bool sex_active, int statsJumpsType, int limit, ArrayList markedRows, int evolution_mark_consecutives, GraphROptions gRO, bool graph, bool toReport, Preferences preferences, TextWriter writer, string fileName, int statCount ) { this.statisticType = statisticType; this.statisticSubType = statisticSubType; this.statisticApplyTo = statisticApplyTo; this.markedRows = markedRows; this.evolution_mark_consecutives = evolution_mark_consecutives; this.graph = graph; this.toReport = toReport; this.writer = writer; this.fileName = fileName; this.statCount = statCount; myStatTypeStruct = new StatTypeStruct ( statisticApplyTo, sendSelectedSessions, sex_active, statsJumpsType, limit, markedRows, gRO, toReport, preferences); myStat = new Stat(); //create and instance of myStat }
private string getRBarplotString(GraphROptions gro, string fileName, Sides side) { string allData = convertDataToR(gro, side); string ylabStr = ""; if(side == Sides.RIGHT) { if(CurrentGraphData.LabelRight != "") ylabStr = ", ylab='" + Util.RemoveTilde(CurrentGraphData.LabelRight) + "'"; } else { //ALL or LEFT if(CurrentGraphData.LabelLeft != "") ylabStr = ", ylab='" + Util.RemoveTilde(CurrentGraphData.LabelLeft) + "'"; } //black only has no sense on barplot if(gro.Palette == Constants.GraphPaletteBlack) gro.Palette="gray.colors"; string rG = //rGraphString " colors=" + gro.Palette +"(length(rownames(data)))\n" + "barplot(data, beside=T, col=colors, lwd="+ gro.LineWidth +", las=2, xlab=''" + ylabStr + ")\n" + " legend('" + gro.Legend +"', legend=rownames(data), cex=.7, col=colors, pch=15)\n"; //have an unique title for both graphs string titStr = getTitle("Barplot",""); if(hasTwoAxis()) { if(side==Sides.RIGHT) rG += "par(mfrow=c(1,1), new=TRUE)\n" + "plot(-1, axes=FALSE, type='n', xlab='', ylab='')\n" + titStr + "par(mfrow=c(1,1), new=FALSE)\n"; } else rG += titStr; return allData + rG; }
private string getRHistogramString(GraphROptions gro, string fileName) { string allData = convertDataToR(gro, Sides.ALL); string titStr = getTitle("Histogram",""); string rG = //rGraphString "hist(serie0, main='', lwd="+ gro.LineWidth +", xlab=colnames(data)[1], cex=1)\n" + "abline(v=mean(serie0, na.rm=T), lwd="+ gro.LineWidth +", lty=1, col='grey20')\n" + "abline(v=median(serie0, na.rm=T), lwd="+ gro.LineWidth +", lty=2, col='grey40')\n" + "mtext('avg', at=mean(serie0, na.rm=T), side=3, cex=.7, col='grey20')\n" + "mtext('median', at=median(serie0, na.rm=T), side=1, cex=.7, col='grey40')\n" + titStr; return allData + rG; }
protected void printStats() { if(StatisticsData.Count > 0) writer.WriteLine("<h2>Statistics</h2>"); //obtain every report stats one by one for(int statCount=0; statCount < StatisticsData.Count ; statCount++) { string [] strFull = StatisticsData[statCount].ToString().Split(new char[] {'\t'}); string myHeaderStat = ""; //separate in sessions ArrayList sendSelectedSessions = GetSelectedSessions(strFull[3]); //separate in markedRows ArrayList arrayListMarkedRows = Util.StringToArrayList(strFull[6], ':'); string applyTo = strFull[2]; myHeaderStat += "<h3> " + strFull[0] + " : " + strFull[1] + " : " + applyTo + "</h3> "; bool showSex = Util.StringToBool(strFull[5]); int limit; int statsJumpsType = GetStatsJumpTypeAndLimit(strFull[4], out limit); //obtain marked jumps of rj evolution if needed string subType; int rj_evolution_mark_consecutives = GetRjEvolutionMarkConsecutives(strFull[1], out subType); myHeaderStat += "\n<p><TABLE cellpadding=2 cellspacing=2><tr><td>\n"; writer.WriteLine(myHeaderStat); StatType myStatType; //bool allFine; //report of stat GraphROptions graphROptions = new GraphROptions(strFull[7]); myStatType = new StatType( strFull[0], //statisticType subType, //statisticSubType strFull[2], //statisticApplyTo sendSelectedSessions, prefsDigitsNumber, showSex, statsJumpsType, limit, heightPreferred, weightStatsPercent, arrayListMarkedRows, rj_evolution_mark_consecutives, graphROptions, false, //graph toReport, writer, "", statCount ); //allFine = myStatType.ChooseStat(); myStatType.ChooseStat(); string myEnunciate ="<tr><td>" + myStatType.Enunciate + "</td></tr>"; writer.WriteLine("<br>"); //report of graph myStatType = new StatType( strFull[0], //statisticType subType, //statisticSubType strFull[2], //statisticApplyTo sendSelectedSessions, prefsDigitsNumber, showSex, statsJumpsType, limit, heightPreferred, weightStatsPercent, arrayListMarkedRows, rj_evolution_mark_consecutives, graphROptions, true, //graph toReport, writer, fileName, //fileName for exporting there statCount ); myStatType.ChooseStat(); //enunciate is prented here and not before //because myStatType of a graph doesn't know the numContinuous value //needed for enunciate in rj evolution statistic writer.WriteLine(myEnunciate); writer.WriteLine("<tr><td>" + strFull[8] + "</td></tr>"); //comment writer.WriteLine("</table>"); } }