//Currently Installed Packages.  pk <- installed.packages()
        public string[] GetInstalledPackages(bool AllLibPaths = true)
        {
            //Get R User lib from config
            //R standard rule: If lib is missing in install.packages(), defaults to the first element of .libPaths().
            //so better pass lib parameter so that user can install his/her own R packages in user personal library.
            string   userRlibConfig = confService.GetConfigValueForKey("userRlib");
            UAReturn result         = IsUserRlibValid(userRlibConfig);

            if (!result.Success)
            {
                string[] error = new string[1];
                error[0] = result.Error;
                return(error);
            }

            string commandstring = string.Empty;

            if (AllLibPaths)
            {
                commandstring = "tmp <- installed.packages(lib.loc= NULL, noCache = TRUE)";
            }
            else //only user-R-lib
            {
                commandstring = "tmp <- installed.packages(lib.loc= '" + userRlibConfig + "', noCache = TRUE)";
            }
            _journal.WriteLine(commandstring);
            _dispatcher.EvaluateToObject(commandstring, false);

            object o = _dispatcher.EvaluateToObject("rownames(tmp)", true); // returns row-header which are packagenames.

            string[] pkgs = this.ObjectToStringArray(o);
            return(pkgs);
        }
Exemple #2
0
        //Currently Installed Packages.  pk <- installed.packages()
        public string[] GetInstalledPackages()
        {
            string commandstring = "tmp <- installed.packages(noCache = TRUE)";

            _journal.WriteLine(commandstring);
            _dispatcher.EvaluateToObject(commandstring, false);

            object o = _dispatcher.EvaluateToObject("rownames(tmp)", true); // returns row-header which are packagenames.

            string[] pkgs = this.ObjectToStringArray(o);
            return(pkgs);
        }
        //Currently Installed Packages.  pk <- installed.packages()
        public string[] GetInstalledPackages()
        {
            string commandstring = "tmp <- installed.packages()";

            _journal.WriteLine(commandstring);
            _dispatcher.EvaluateToObject(commandstring, false);

            // tmp contains following fields(info about packages )
            // <row-header is packagename>, Package, LibPath, Version, Priority, Depends, Imports,
            // LinkingTo, Suggests, Enhances, OS_type, License, Built.

            // commandstring=".packages(all.available = TRUE)" //command can also be used below. just one command is enough instead of 2.
            object o = _dispatcher.EvaluateToObject("rownames(tmp)", true); // returns row-header which are packagenames.

            string[] pkgs = this.ObjectToStringArray(o);
            return(pkgs);
        }