Пример #1
0
        public static DataTable PCALoadingstoDataTable(RDotNet.DataFrame dataFrame)
        {
            try
            {
                DataTable dtable = new DataTable();

                dtable.Columns.Add("Component");

                for (int i = 0; i < dataFrame.ColumnCount; ++i)
                {
                    dtable.Columns.Add(dataFrame.ColumnNames[i]);
                }

                for (int i = 0; i < dataFrame.RowCount; i++)
                {
                    DataRow newRow = dtable.Rows.Add();
                    newRow[0] = "PC " + (i + 1);
                    for (int j = 0; j < dataFrame.ColumnCount; j++)
                    {
                        newRow[j + 1] = Math.Round(Double.Parse(dataFrame[i, j].ToString()), 3);
                    }
                }

                return(dtable);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
            return(null);
        }
Пример #2
0
        public static DataTable CorelationFrameToDataTable(RDotNet.DataFrame dataFrame)
        {
            try
            {
                DataTable dtable = new DataTable();

                dtable.Columns.Add("item");
                for (int i = 0; i < dataFrame.ColumnCount; ++i)
                {
                    dtable.Columns.Add(dataFrame.ColumnNames[i]);
                }

                for (int i = 0; i < dataFrame.RowCount; i++)
                {
                    DataRow newRow = dtable.Rows.Add();
                    newRow[0] = dataFrame.ColumnNames[i];
                    for (int j = 0; j < dataFrame.ColumnCount; j++)
                    {
                        newRow[j + 1] = dataFrame[i, j];
                    }
                }

                return(dtable);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
            return(null);
        }
Пример #3
0
        public static DataTable PCATableToDataTable(RDotNet.DataFrame dataFrame)
        {
            try
            {
                DataTable dtable = new DataTable();

                dtable.Columns.Add("");

                for (int i = 0; i < dataFrame.ColumnCount; ++i)
                {
                    dtable.Columns.Add("PC " + (i + 1));
                }

                for (int i = 0; i < dataFrame.RowCount; i++)
                {
                    DataRow newRow = dtable.Rows.Add();
                    switch (i)
                    {
                    case 0:
                        newRow[0] = "Value";
                        break;

                    case 1:
                        newRow[0] = "Varriability (%)";
                        break;

                    case 2:
                        newRow[0] = "Cumulated Value";
                        break;

                    case 3:
                        newRow[0] = "Cumulated V (%)";
                        break;
                    }
                    for (int j = 0; j < dataFrame.ColumnCount; j++)
                    {
                        if (i == 0 || i == 2)
                        {
                            newRow[j + 1] = Math.Round(Double.Parse(dataFrame[i, j].ToString()), 7);
                        }
                        else
                        {
                            newRow[j + 1] = Math.Round(Double.Parse(dataFrame[i, j].ToString()), 3) + "%";
                        }
                    }
                }

                return(dtable);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
            return(null);
        }
Пример #4
0
        private void toolStripMenuItemStatsElementsConstructs_Click(object sender, EventArgs e)
        {
            try
            {
                dlgValues dlg = new dlgValues();
                dlg.Text           = "Please provide custom parameters for the statsConstructs function";
                dlg.AcceptedValues = InterviewService.StatsGridAcceptedValues();
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    throw new Exception("Aborted by User");
                }

                RDotNet.DataFrame df = this.interviewService.StatsGrid(false, dlg.OptionalValues);
                RHelper.RHelper.FillDataGridViewFromR(df, getDGV(getNewTabpage("statsConstructs")), 3);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error while Calculating statistics for Constructs");
            }
        }
Пример #5
0
        private void rootMeanSquareCorrelationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                dlgValues dlg = new dlgValues();
                dlg.Text           = "Please provide custom parameters for the elementRmsCor function";
                dlg.AcceptedValues = InterviewService.CorrelationRMSAcceptedValues();
                if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    throw new Exception("Aborted by User");
                }

                RDotNet.DataFrame df = this.interviewService.CorrelationRMS(true, dlg.OptionalValues);
                RHelper.RHelper.FillDataGridViewFromR(df, getDGV(getNewTabpage("elementRmsCor")), 3);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.StackTrace);
                MessageBox.Show(ex.Message, "Error while Calculating Root mean square correlation for Elements");
            }
        }