Installing R package in Azure Machine Learning

We already know that Azure Machine Learning(https://studio.azureml.net/) supports for R language which makes our life easier to use our own existing R code with in AML studio.

There are over 400 most popular R packages pre-install in the Azure Machine Learning Studio.

How to find the list of packages that are currently supported or installed, you can use the below script:

Use Execute R script task in AML studio and copy paste the below script:

out <- data.frame(installed.packages(,,,fields="Description"))
maml.mapOutputPort("out")  

If you want, you can also convert the output to a CSV file using Convert to CSV:

Now the biggest issue is when we try to execute our existing R code which have R packages not pre-install or supported in AML. You will end up getting Error: could not find function "<packagename>" or package '<packagename>'is not available or there is no package called '<packagename>'

You need to upload/install the R package with Azure Machine Learning Studio to execute you code.

Here are the Steps How to install/upload outside R package in Azure Machine Learning studio:

I will be using dummies R package in my example for the installation:

  1. Download the R package dummies or which you want to install, you can use R studio to do this if the package is not yet install in the R package library. Location will be: C:\Users\ <username>\Documents\R\win-library\3.2
  2. Put dummies package into a .zip folder as shown below:
  1. Now the most important step where most of us making mistake is we need to again put the .zip folder to another .zip folder. Which means dummies.zip -> dummies (2).zip
  2. You can rename the final zip folder as per your wish let say in my case I renamed it to pack.zip

  1. Upload the final pack.zip file to the Azure Machine Learning Data Set:

  2. Under saved data set drag and drop the .zip package file

  3. Use Execute R script task in AML studio and copy paste the below script:

    install.packages("src/pack/dummies.zip", lib = ".", repos = NULL, verbose = TRUE)
    library(dummies, lib.loc=".", verbose=TRUE)

     

  4. This will successful install the dummies R package.

Please note if you are getting the below error while running you R script, please do zip of you zip, as mention in the step 3.

Error 0063: The following error occurred during evaluation of R script:

---------- Start of error message from R ----------

zip file 'src/dummies.zip' not found

I hope this blog will help you to know how to check the pre-install, and how to install you own R package within Azure ML Studio and handle ErrorCode":"0063.

Gaurav Agarwal