Exemplo n.º 1
0
        private void Add_Factor()
        {
            var tmpfactorInfo = new clsFactorInfo();

            if (lstBoxFactors.Items.Count == MAX_LEVELS)
            {
                MessageBox.Show("Maximum number of factors reached!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else if (txtBoxFactors.Text != "")
            {
                var strFactor = txtBoxFactors.Text.Replace(" ", "_");
                if (Array.IndexOf(strarrFactors, strFactor) < 0)
                { // no duplicates
                    txtBoxFactors.Text       = "";
                    tmpfactorInfo.mstrFactor = strFactor;
                    marrFactors.Add(tmpfactorInfo);
                    lstBoxFactors.Items.Add(strFactor);
                    lstBoxFactors.SelectedIndex = -1;
                    strarrFactors[numFactors]   = strFactor;
                    numFactors++;
                }
                else
                {
                    MessageBox.Show("You have already entered this factor!", "Existing Factor", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Exemplo n.º 2
0
        private void UpdateFactorInfoArray()
        {
            var factorValues = new List <string>();

            marrFactorInfo.Clear();
            try
            {
                mRConnector.EvaluateNoReturn("factorNames <- rownames(factors)");
                var factorNamesFromR = mRConnector.GetSymbolAsStrings("factorNames");
                var factorNames      = factorNamesFromR;

                for (var numF = 0; numF < factorNames.Length; numF++)
                {
                    factorValues.Clear();
                    mRConnector.EvaluateNoReturn("fVals <- unique(factors[" +
                                                 Convert.ToString(numF + 1) + ",])");
                    mRConnector.EvaluateNoReturn("nfVals <- length(fVals)");

                    var factorValuesFromR = mRConnector.GetSymbolAsStrings("fVals");
                    var factorCountsFromR = mRConnector.GetSymbolAsNumbers("nfVals");

                    if ((int)factorCountsFromR[0] > 1)
                    {
                        //more than one factor value
                        factorValues.AddRange(factorValuesFromR);
                    }
                    else
                    {
                        factorValues.Add(factorValuesFromR[0]);
                    }

                    var currFactorInfo = new clsFactorInfo
                    {
                        SetFvals   = factorValues,
                        mstrFactor = factorNames[numF]
                    };

                    marrFactorInfo.Add(currFactorInfo);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Exception while talking to R");
            }
        }