예제 #1
0
 public void FrequencyTableContinuous()
 {
     var f0 = new FieldRange("Data selection", "Data", _range, false);
     var f1 = new FieldNumber("Nb of classes", "Number of classes", 10, true);
     var f2 = new FieldNumber("Class precision", "Number of digits after the decimal point", 0, 0, 15, true);
     var inputbox = new InputBox(_excelapp, "Create frequency chart", f0, f1, f2);
     inputbox.RestoreSelectionOnExit = false;
     inputbox.Show(delegate {
         var rgsel = f0.Value;
         var nbClasses = (int)(f1.Value ?? 0);
         var precision = (int)(f2.Value ?? 0);
         var classes = Frequency.ComputeContinuousFrequencies(rgsel, nbClasses, precision);
         var nbValues = classes.Values.Length;
         var table = new object[nbValues + 1, 2];
         table[0, 0] = "Class";
         table[0, 1] = "Frequence";
         for (int i = 0; i < nbValues; i++) {
             table[i + 1, 0] = classes.Names[i];
             table[i + 1, 1] = classes.Values[i];
         }
         AddTableToNewSheet(table);
     });
 }
예제 #2
0
        public void FrequencyTableDiscete()
        {
            var f0 = new FieldRange("Data selection", null, _range, false);
            var f1 = new FieldRadioBT("Order by", new string[] { "Value", "Freq Asc", "Freq Desc" }, null, 0, true);
            var inputbox = new InputBox(_excelapp, "Create frequency chart", f0, f1);
            inputbox.RestoreSelectionOnExit = false;
            inputbox.Show(delegate {
                var rgsel = f0.Value;
                var orderByFrequencyAsc = f1.Value == 1;
                var orderByFrequencyDesc = f1.Value == 2;
                var freq = Frequency.ComputeDisceteFrequencies(rgsel);
                if (orderByFrequencyAsc)
                    freq.SortByFrequenceAsc();
                else if (orderByFrequencyDesc)
                    freq.SortByFrequenceDesc();

                var nbValues = freq.Frequencies.Length;
                var table = new object[nbValues + 1, 2];
                table[0, 0] = "Value";
                table[0, 1] = "Frequence";
                for (int i = 0; i < nbValues; i++) {
                    table[i + 1, 0] = freq.Values[i];
                    table[i + 1, 1] = freq.Frequencies[i];
                }
                AddTableToNewSheet(table);
            });
        }