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

Comments

  • Anonymous
    December 02, 2016
    Good one
    • Anonymous
      December 02, 2016
      Thanks Rajat!
  • Anonymous
    December 02, 2016
    Super Informative will share with my Data Science team...
    • Anonymous
      December 05, 2016
      Thanks Karan!
  • Anonymous
    January 11, 2017
    Thanks for all the details .. it wil help me to test Boruta package under Azure ML
  • Anonymous
    January 11, 2017
    I have tried to download as you mention ... but it doesn't work always the error 063Can you explain what you see on the Visualisation of pack.zip (4 columns)Why src/ .... Thanks
    • Anonymous
      January 11, 2017
      make sure you put the.zip folder to another .zip folder. Meaning the R package need to be zip and zip it again to make it the final .zip folder
  • Anonymous
    January 13, 2017
    Thanks Gaurav. But in case others find it helpful, this only works for me if I drop the intermediate zip file name from the installation path. In other words, instead of writing...install.packages(“src/pack/dummies.zip”, lib = “.”, repos = NULL, verbose = TRUE)I needed to write...install.packages(“src/dummies.zip”, lib = “.”, repos = NULL, verbose = TRUE)I still have the zipped dummies package located inside the "pack.zip" dataset, but I get that pesky 0063 error if I include the word "pack" in the installation path.
    • Anonymous
      March 31, 2017
      Thanks for the comment. This worked for me also.
      • Anonymous
        December 19, 2017
        Thanks for the comment. After several attempts, this worked for me also.
    • Anonymous
      January 22, 2018
      This works for me as well. thanks.
  • Anonymous
    January 18, 2017
    I am running into a similar error. Error 0063: unexpected input. There is an indicator mark at the name of the package I want to load:5: install.packages("src/lubridatepack/lubridate.zip", lib = ? ^I have zipped my zip, so I am at a loss for what I am doing wrong. Any help would be appreciated.
    • Anonymous
      January 18, 2017
      That marker should be under "lubridate.zip"
    • Anonymous
      January 18, 2017
      please use the below code it should work without fail:install.packages(“src/lubridatepack/lubridate.zip”, lib = “.”, repos = NULL, verbose = TRUE)library(lubridate, lib.loc=”.”, verbose=TRUE)where lubridatepack is a zip folder inside that you will have lubridate.zip
      • Anonymous
        January 18, 2017
        Thank you for the quick response. Unfortunately, that is exactly the code I ran and I am still getting an error. Inside the zip folders, how is it supposed to look? I have lubdridatepack.zip → lubridate.zip → lubridate → the package files
        • Anonymous
          January 18, 2017
          I think my problem is because lubridate is already installed. When I first ran my code I got an error that I thought was telling me that lubridate had not been found. However, I am new to AML and think I misinterpreted that error message.
  • Anonymous
    March 09, 2017
    Hi Agarwal and first of all, thanks for this post. I've followed all the steps but unfortunately still get this error: zip file 'src/pack/dummies.zip' not found1. I've zipped the folder of the dummies library2. I've zipped that into pack.zip3. I've uploaded pack.zip as a dataset and added it to my experiment in AML 4. I'm using this ti load it install.packages("src/pack/dummies.zip", lib = ".", repos = NULL, verbose = TRUE)library(dummies, lib.loc=".", verbose=TRUE)If you notice the error I'm getting is not identical to the one you include in the article. The error in my case contains the correct indicated path. Any help or suggestions, greatly appreciated. Thanks,Spyros
    • Anonymous
      March 09, 2017
      Hi Sypros,I am not sure why this is happening, it should work if you have pointed the package location correctly and following the instruction as mentioned.
  • Anonymous
    October 12, 2017
    Thanks alot. Keep sharing.!!!