08-30-2018 08:54 AM - edited 08-03-2021 03:36 PM
Ris an open-source programming language and software environment, specifically intended for statistical computing and graphics. The Alteryx Predictive Tools install includes an installation of R, along with a set of R Packagesused by the Predictive Tools.
Packagesare user-created collections of R functions, data and compiled code. R packages are an easy way to share and implement different statistical techniques and other functions in R, and a large part of what makes R so popular and robust.
The directory where the packages are stored is called the library. One instance of R can have multiple libraries associated with it. The R function .libPaths() returns the file paths of any libraries associated with the current R session.
If you’ve ever wondered what R packages are installed on your machine in association with R, I have developed a little bit of code that you can put into your R Tool and run. The output will be a list of the installed R packages and a description of each of their uses.
#get general information about R version version
This code first extracts the version information of the R session, then it accesses the package and version information for all installed packages with the installed.packages function, and converts the output to a data frame. After extracting the packages and version information, the rownames of the dataframe are removed by setting the row names to NULL. Finally, an associated package description is attached for each installed package.
In the attached workflow, I have pasted this code into an R Tool, along with write.Alteryx functions to write all of this information out into a data stream.
#write out to datastream #packages write.Alteryx(packages, 1) #version info write.Alteryx(version, 2)
This information can help you with package management and version control. Occasionally, having mismatching R or R-package versions between where code is developed and where the code is executed (e.g., the R Tool) can cause unexpected behavior.
In addition to a bunch of open-source packages from various authors, there are a handful of Alteryx R packages that are installed with the Predictive Tools. The github repository for these packages can be found athttps://github.com/alteryx
There are six Alteryx-specific R packages on this repository that are important to highlight:
Great post @SydneyF!!
Also, I have found the following columns -provided by installed.packages()- helpful when investigating packages issues:
LibPath: location of the library on the machine
Depends: dependencies (R version, other libraries,...)
Imports: packages used but not attached (like calls involving "::" or ":::" for instance)
Built: version of R used to build the package
Source: https://cran.r-project.org/doc/manuals/r-release/R-exts.html
Example:
write.Alteryx(as.data.frame(installed.packages()[,c("Package","Version","LibPath","Depends","Imports","Built")]),1)
Thanks,
PaulN