private static void CreateMatrixData(CountingResult result, IMatrixData data, int minCount, IEnumerable selection) { List <string[]> type = new List <string[]>(); List <string[]> name = new List <string[]>(); List <double> count = new List <double>(); List <double> percOfTotal = new List <double>(); List <double> selCount = new List <double>(); List <double> selPerc = new List <double>(); for (int i = 0; i < result.Count; i++) { int c = result.GetTotalCountAt(i); if (c < minCount) { continue; } type.Add(new[] { result.GetType1At(i) }); name.Add(new[] { result.GetName1At(i) }); count.Add(c); percOfTotal.Add(Math.Round(10000.0 * c / data.RowCount) / 100.0); if (selection != null) { int c1 = result.GetSelectCountAt(i); selCount.Add(c1); selPerc.Add(Math.Round(1000.0 * c1 / c) / 10.0); } } float[,] ex = new float[type.Count, 0]; List <string[][]> catCols = new List <string[][]> { type.ToArray(), name.ToArray() }; List <string> catColNames = new List <string>(new[] { "Type", "Name" }); List <double[]> numCols = new List <double[]> { count.ToArray(), percOfTotal.ToArray() }; if (selection != null) { numCols.Add(selCount.ToArray()); numCols.Add(selPerc.ToArray()); } List <string> numColNames = new List <string>(new[] { "Count", "Percentage of total" }); if (selection != null) { numColNames.AddRange(new[] { "Selection count", "Selection percentage" }); } data.Name = "Count"; data.ColumnNames = new List <string>(); data.Values.Set(ex); data.SetAnnotationColumns(new List <string>(), new List <string[]>(), catColNames, catCols, numColNames, numCols, new List <string>(), new List <double[][]>()); }
private static void CreateMatrixData(CountingResult result, IMatrixData data, int minCount, IEnumerable selection) { List<string[]> type = new List<string[]>(); List<string[]> name = new List<string[]>(); List<double> count = new List<double>(); List<double> percOfTotal = new List<double>(); List<double> selCount = new List<double>(); List<double> selPerc = new List<double>(); for (int i = 0; i < result.Count; i++){ int c = result.GetTotalCountAt(i); if (c < minCount){ continue; } type.Add(new[]{result.GetType1At(i)}); name.Add(new[]{result.GetName1At(i)}); count.Add(c); percOfTotal.Add(Math.Round(10000.0*c/data.RowCount)/100.0); if (selection != null){ int c1 = result.GetSelectCountAt(i); selCount.Add(c1); selPerc.Add(Math.Round(1000.0*c1/c)/10.0); } } float[,] ex = new float[type.Count,0]; List<string[][]> catCols = new List<string[][]>{type.ToArray(), name.ToArray()}; List<string> catColNames = new List<string>(new[]{"Type", "Name"}); List<double[]> numCols = new List<double[]>{count.ToArray(), percOfTotal.ToArray()}; if (selection != null){ numCols.Add(selCount.ToArray()); numCols.Add(selPerc.ToArray()); } List<string> numColNames = new List<string>(new[]{"Count", "Percentage of total"}); if (selection != null){ numColNames.AddRange(new[]{"Selection count", "Selection percentage"}); } data.SetData("Count", new List<string>(), ex, new List<string>(), new List<string[]>(), catColNames, catCols, numColNames, numCols, new List<string>(), new List<double[][]>()); }