BSky.Statistics.R.RPackageManager.UninstallPackage C# (CSharp) Method

UninstallPackage() public method

public UninstallPackage ( string packagename ) : UAReturn
packagename string
return BSky.Statistics.Common.UAReturn
        public UAReturn UninstallPackage(string packagename)
        {
            //first find the lib where package is installed
            string lib = _dispatcher.EvaluateToObject("find.package('"+packagename.Trim()+"')", true).ToString();//this must be path with forward slash(Unix style)
            lib = lib.Substring(0, lib.IndexOf(packagename) - 1);
            //Now the pacakge will get removed from right location
            string command = "remove.packages('" + packagename + "', lib='"+lib+"')";

            UAReturn result = new UAReturn() { Success = false };
            UnLoadPackage(packagename); // if its loaded, unload it first.
            // now remove package
            //_dispatcher.EvaluateNoReturn("library(tools)"); //already excuted in constructor
            string errmsg = _dispatcher.EvaluateNoReturn(command);//  "Uninstall Package";
            _journal.WriteLine(command);
            if (errmsg != null && errmsg.Trim().Length > 1) //error occurred
            {
                result.Error = errmsg;
            }


            result.Success = true;
            result.CommandString = command;
            return result;
        }