Hi,
I have Four scenarios on installing packages in R console from Alteryx Designer- Out of which three of them fails and shows the error-Error: R (1): Error in install.packages("package name") : unable to install packages.
Scenario- 1- Trying to install fpp2 package
I used a simple code- install.packages("fpp2") to install fpp2 package- it failed
Scenario- 2- Trying to install fpp2 package- using conditional install
cond.install <- function(package.name){
options(repos = "http://cran.rstudio.com")
if(package.name%in%rownames(installed.packages())==FALSE) {
install.packages(package.name)}else{require(package.name, character.only = TRUE)}}
cond.install("fpp2")
library("fpp2")
It failed saying couldn't install the package
Scenario- 3- Trying to install data.table package
I used a simple code- install.packages("data.table") to install data.table package- it failed
Scenario- 4- Trying to install data.table package using conditional install
cond.install <- function(package.name){
options(repos = "http://cran.rstudio.com")
if(package.name%in%rownames(installed.packages())==FALSE) {
install.packages(package.name)}else{require(package.name, character.only = TRUE)}}
cond.install("data.table")
library("data.table")
It compiled with no error
So if anyone could help me on how to install packages in R and why does the simple install.package code fails while installing both packages and conditional install works fine only with data.table package.
Please help me with the best method to install packages in R console from Alteryx Deisgner.
As i'm new to this and trying to learn.
We use Alteryx Designer 2020.2 and Alteryx Predictive tools with R 3.6.3- Admin version
Please advise
Thank you
try install.packages("fpp2",repos="http://cran.rstudio.com")
Note - this is a moderately old version of R so you may need to a point to a specific version of the package which is compatible with it.
Note 2 - Try running designer as administrator
Note 3- I manage my packages by installing in Rstudio to a path which is accessible to both Rstudio and Alteryx.
I always try installing via Designer first with this code in the R tool:
install.packages([package name],repos='http://cran.us.r-project.org', dependencies=TRUE)
If that fails (and sometimes it does), I go to the Alteryx R-root folder (C:\Program Files\Alteryx\R-[version]\bin) and run it through the "R.exe" executable by entering install.packages([package name]), which will then bring up a list of mirrors and you select one (I usually select one nearest to my state). That usually does the trick.
I find the install package functionality within Alteryx to be very inconsistent and not user-friendly. Also, when doing it through Designer, if on Windows 10 or higher, you'll have to right click the Alteryx icon and "run as administrator".