2
votes

I'm trying to use the R sentimentr package on Azure ML Studio. As this package is not supported, I'm trying to install it and its dependencies as described in the documentation.

The steps that I have performed are:

  • downloaded Windows binaries from the R Open 3.4.4 snapshot at CRAN time machine

    • sentimentr_2.2.3.zip
    • syuzhet_1.0.4.zip
    • textclean_0.6.3.zip
    • lexicon_0.7.4.zip
    • textshape_1.5.0.zip
  • zipped those zip files into a zipped folder packages.zip

  • uploaded packages.zip as a dataset to Microsoft Azure ML Studio

In my ML experiment I connect the packages.zip dataset to the "Script Bundle (Zip)" input port on "Execute R Script" and include this code:

# install R package contained in src  
install.packages("src/lexicon_0.7.4.zip", 
                 lib = ".", 
                 repos = NULL, 
                 verbose = TRUE)  

install.packages("src/textclean_0.6.3.zip", 
                 lib = ".", 
                 repos = NULL, 
                 verbose = TRUE)  

install.packages("src/textshape_1.5.0.zip", 
                 lib = ".", 
                 repos = NULL, 
                 verbose = TRUE)  

install.packages("src/syuzhet_1.0.4.zip", 
                 lib = ".", 
                 repos = NULL, 
                 verbose = TRUE)  

install.packages("src/sentimentr_2.2.3.zip", 
                 lib = ".", 
                 repos = NULL, 
                 verbose = TRUE)  

# load libraries
library(sentimentr, lib.loc = ".", verbose = TRUE)

The experiment runs successfully, until I include a function from sentimentr:

mydata <- mydata %>%
  get_sentences() %>%
  sentiment()

This gives the error:

there is no package called 'textshape'

Which is difficult to understand given that the output log does not indicate an issue with the packages:

[Information]         The following files have been unzipped for sourcing in path=["src"]:
[Information]                           Name  Length                Date
[Information]         1 sentimentr_2.2.3.zip 3366245 2019-08-07 14:57:00
[Information]         2    syuzhet_1.0.4.zip 2918474 2019-08-07 15:05:00
[Information]         3  textclean_0.6.3.zip 1154814 2019-08-07 15:13:00
[Information]         4    lexicon_0.7.4.zip 4551995 2019-08-07 15:17:00
[Information]         5  textshape_1.5.0.zip  463095 2019-08-07 15:42:00
[Information]         Loading objects:
[Information]           port1
[Information]         [1] "Loading variable port1..."
[Information]         package 'lexicon' successfully unpacked and MD5 sums checked   
[Information]         package 'textclean' successfully unpacked and MD5 sums checked
[Information]         package 'textshape' successfully unpacked and MD5 sums checked
[Information]         package 'syuzhet' successfully unpacked and MD5 sums checked
[Information]         package 'sentimentr' successfully unpacked and MD5 sums checked

Has anyone seen this, or similar issues? Is it possible that "successfully unpacked" is not the same as successfully installed and usable?

1

1 Answers

0
votes

I can now answer my own question thanks to a hint on Twitter from @bryan_hepworth.

The R packages were installed correctly, but not in the standard library location. So when a function from sentimentr runs, R tries to load the dependency package textshape:

library(textshape)

Which of course does not exist in the standard location as Azure ML does not support it.

The solution is to load textshape explicitly from its installed location:

library(textshape, lib.loc = ".")

So the solution is: explicitly load packages that you installed at the start of your R code, rather than letting R try to load them as dependencies, which will fail.