public DatatableBag(DataTable dt, string crosstab, List <EpiDashboard.DescriptiveStatistics> descStatsList = null, GridCells gridCells = null, int observations = 4) { _tableName = dt.TableName; _gridCellData = gridCells; _exposure = crosstab; this.descriptiveStatisticsList = descStatsList; foreach (DataColumn col in dt.Columns) { columnNameList.Add(new MyString(col.ColumnName)); } foreach (DataRow row in dt.Rows) { fieldsList = new FieldsList(); foreach (DataColumn col in dt.Columns) { fieldsList.Fields.Add(new MyString(row[col.ColumnName].ToString())); } recordList.Add(fieldsList); } }
public void AddResult(DataTable table, string crosstab, List <DescriptiveStatistics> statsList, GridCells gridCells) { freqResultsDataTableList.Add(table); this.FreqResultsDescriptiveStatistics = statsList; Array.Resize(ref datatableBagArray, datatableBagArray.Length + 1); DatatableBag bag = new DatatableBag(table, crosstab, statsList, gridCells); datatableBagArray[datatableBagArray.Length - 1] = bag; }
//void Swap2x2RowValues(DataTable table) //{ // if (table.Rows.Count > 2 || table.Columns.Count > 3) // { // return; // cannot do an invalid 2x2 table // } // object row1Col1 = table.Rows[0][1]; // object row1Col2 = table.Rows[0][2]; // object row2Col1 = table.Rows[1][1]; // object row2Col2 = table.Rows[1][2]; // table.Rows[0][1] = row2Col1; // table.Rows[0][2] = row2Col2; // table.Rows[1][1] = row1Col1; // table.Rows[1][2] = row1Col2; // object firstRowName = table.Rows[0][0]; // table.Rows[0][0] = table.Rows[1][0]; // table.Rows[1][0] = firstRowName; //} //void Swap2x2ColValues(DataTable table) //{ // if (table.Rows.Count > 2 || table.Columns.Count > 3) // { // return; // cannot do an invalid 2x2 table // } // object row1Col1 = table.Rows[0][1]; // object row1Col2 = table.Rows[0][2]; // object row2Col1 = table.Rows[1][1]; // object row2Col2 = table.Rows[1][2]; // table.Rows[0][1] = row1Col2; // table.Rows[0][2] = row1Col1; // table.Rows[1][1] = row2Col2; // table.Rows[1][2] = row2Col1; // string firstColumnName = table.Columns[1].ColumnName; // string secondColumnName = table.Columns[2].ColumnName; // table.Columns[1].ColumnName = "_COL1_"; // table.Columns[2].ColumnName = "_COL2_"; // table.Columns[1].ColumnName = secondColumnName; // table.Columns[2].ColumnName = firstColumnName; //} private TwoxTwoAndMxNResultsSet Setup2x2(GadgetParameters gadgetOptions, TwoxTwoAndMxNResultsSet resultSet) { GridCells gridCells = new GridCells(); TwoxTwoTableDTO table = resultSet.TwoxTwoTableDTO; DataTable dt = resultSet.FreqResultsDataTable; if (table != null) // && table.Rows.Length != 0) { //if (gadgetOptions.InputVariableList.ContainsKey("smarttable") && gadgetOptions.InputVariableList["smarttable"].Equals("true")) //{ // CheckLabels(table); //} gridCells.yyVal = Convert.ToInt32(dt.Rows[0][1].ToString()); //table.Yy; gridCells.ynVal = Convert.ToInt32(dt.Rows[0][2].ToString()); //table.Yn; gridCells.nyVal = Convert.ToInt32(dt.Rows[1][1].ToString()); //table.Ny; gridCells.nnVal = Convert.ToInt32(dt.Rows[1][2].ToString()); //table.Nn; gridCells.ntVal = gridCells.nnVal + gridCells.nyVal; gridCells.ytVal = gridCells.yyVal + gridCells.ynVal; gridCells.ttVal = gridCells.ytVal + gridCells.ntVal; gridCells.tyVal = gridCells.yyVal + gridCells.nyVal; gridCells.tnVal = gridCells.ynVal + gridCells.nnVal; if (gridCells.ytVal != 0) { gridCells.yyRowPct = 1.0 * gridCells.yyVal / gridCells.ytVal; gridCells.ynRowPct = 1.0 * gridCells.ynVal / gridCells.ytVal; } if (gridCells.ntVal != 0) { gridCells.nyRowPct = 1.0 * gridCells.nyVal / gridCells.ntVal; gridCells.nnRowPct = 1.0 * gridCells.nnVal / gridCells.ntVal; } if (gridCells.tyVal != 0) { gridCells.yyColPct = 1.0 * gridCells.yyVal / gridCells.tyVal; gridCells.nyColPct = 1.0 * gridCells.nyVal / gridCells.tyVal; } if (gridCells.tnVal != 0) { gridCells.ynColPct = 1.0 * gridCells.ynVal / gridCells.tnVal; gridCells.nnColPct = 1.0 * gridCells.nnVal / gridCells.tnVal; } if (gridCells.ttVal != 0) { gridCells.tyRowPct = 1.0 * gridCells.tyVal / gridCells.ttVal; gridCells.tnRowPct = 1.0 * gridCells.tnVal / gridCells.ttVal; gridCells.ytColPct = 1.0 * gridCells.ytVal / gridCells.ttVal; gridCells.ntColPct = 1.0 * gridCells.ntVal / gridCells.ttVal; } if (gridCells.tyVal > 0 && gridCells.tnVal > 0 && gridCells.ytVal > 0 && gridCells.ntVal > 0) { //gridCells.singleTableResults = new StatisticsRepository.cTable().SigTable( // (double)gridCells.yyVal, (double)gridCells.ynVal, // (double)gridCells.nyVal, (double)gridCells.nnVal, 0.95); StatisticsRepository.cTable.SingleTableResults stab = new StatisticsRepository.cTable().SigTable( (double)gridCells.yyVal, (double)gridCells.ynVal, (double)gridCells.nyVal, (double)gridCells.nnVal, 0.95); //gridCells.singleTableResults = new MySingleTableResults() //{ // ChiSquareMantel2P = stab.ChiSquareMantel2P, // ChiSquareUncorrected2P = stab.ChiSquareUncorrected2P, // ChiSquareMantelVal = stab.ChiSquareMantel2P //} gridCells.singleTableResults = new MySingleTableResults() { ChiSquareMantel2P = stab.ChiSquareMantel2P, ChiSquareMantelVal = stab.ChiSquareMantelVal, ChiSquareUncorrected2P = stab.ChiSquareUncorrected2P, ChiSquareUncorrectedVal = stab.ChiSquareUncorrectedVal, ChiSquareYates2P = stab.ChiSquareYates2P, ChiSquareYatesVal = stab.ChiSquareYatesVal, ErrorMessage = stab.ErrorMessage, FisherExact2P = stab.FisherExact2P, FisherExactP = stab.FisherExactP, MidP = stab.MidP, OddsRatioEstimate = stab.OddsRatioEstimate, OddsRatioLower = stab.OddsRatioLower, OddsRatioMLEEstimate = stab.OddsRatioMLEEstimate, OddsRatioMLEFisherLower = stab.OddsRatioMLEFisherLower, OddsRatioMLEFisherUpper = stab.OddsRatioMLEFisherUpper, OddsRatioMLEMidPLower = stab.OddsRatioMLEMidPLower, OddsRatioMLEMidPUpper = stab.OddsRatioMLEMidPUpper, OddsRatioUpper = stab.OddsRatioUpper, RiskDifferenceEstimate = stab.RiskDifferenceEstimate, RiskDifferenceLower = stab.RiskDifferenceLower, RiskDifferenceUpper = stab.RiskDifferenceUpper, RiskRatioEstimate = stab.RiskRatioEstimate, RiskRatioLower = stab.RiskRatioLower, RiskRatioUpper = stab.RiskRatioUpper }; } } if (gridCells.singleTableResults != null && !string.IsNullOrEmpty(gridCells.singleTableResults.ErrorMessage)) { //this.Dispatcher.BeginInvoke(new SimpleCallback(ClearSingleResults)); //this.Dispatcher.BeginInvoke(new ShowErrorMessage(ShowError), gridCells.singleTableResults.ErrorMessage); // this.Dispatcher.BeginInvoke(new RenderFinishWithErrorDelegate(RenderFinishWithError), gridCells.singleTableResults.ErrorMessage); // RenderFinishWithError(gridCells.singleTableResults.ErrorMessage); // resultSet.AddError(thisStringLiterals.RenderFinishWithError, gridCells.singleTableResults.ErrorMessage); //stopwatch.Stop(); //Debug.Print("2x2 table gadget took " + stopwatch.Elapsed.ToString() + " seconds to complete with " + dashboardHelper.RecordCount.ToString() + " records and the following filters:"); //Debug.Print(dashboardHelper.DataFilters.GenerateDataFilterString()); } else { // RenderGridCells(gridCells, table); // RenderFinish(); resultSet.GridCells = gridCells; } return(resultSet); }