Install Package in Jupyter Notebook, Anaconda - r

I'm running R language with Jupyter Notebook using Anaconda via Environments - not R Studio.
I'm trying to install R packages but it gives me the following errors:
install.packages('agricolae', repos="http://cran.rstudio.com/")
also installing the dependencies ‘units’, ‘sf’, ‘spdep’
Warning message in install.packages("agricolae", repos = "http://cran.rstudio.com/"):
“installation of package ‘units’ had non-zero exit status”Warning message in install.packages("agricolae", repos = "http://cran.rstudio.com/"):
“installation of package ‘sf’ had non-zero exit status”Warning message in install.packages("agricolae", repos = "http://cran.rstudio.com/"):
“installation of package ‘spdep’ had non-zero exit status”Warning message in install.packages("agricolae", repos = "http://cran.rstudio.com/"):
“installation of package ‘agricolae’ had non-zero exit status”Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Then I try to load the library
library("agricolae")
Error in library("agricolae"): there is no package called ‘agricolae’
Traceback:
library("agricolae")
If I open with R Studio, I can make it work.
Does anybody know how to solve the issue on Jupyter Notebook?, I'm using macOs sierra 10.12.6.
Thank you very much

Related

Installing R packages on Azure failed: non-zero exit status

I just started using RStudio on Azure Databricks. After I select the cluster and click on the Libraries tab I managed to install few extra packages (timetk, tidymodels, rules, doFutures). But when I tried to install the modelitme package I got the following error:
java.lang.RuntimeException: Installation failed with message:
Error installing R package: Could not install package with error: installation of package ‘V8’ had non->zero exit status installation of package ‘rstan’ had non-zero exit status installation of package >‘prophet’ had non-zero exit status installation of package ‘modeltime’ had non-zero exit status Full >error log available at /databricks/driver/library-install-logs/r-package-installation-2020-10->03T10:31:18Z-vcap9s0e.log
Error installing R package: Could not install package with error: installation of package ‘V8’ had non->zero exit status installation of package ‘rstan’ had non-zero exit status installation of package >‘prophet’ had non-zero exit status installation of package ‘modeltime’ had non-zero exit status
How do I solve problem like this?

Could not install R package source in R-studio

I have a source of one R package (http://stat.snu.ac.kr/heeseok/autots). I would like to install it in R-studio, however, I got an error.
Here is my try:
install.packages("/Users/Mary/Downloads/autots_2.3.3.tar.gz", repos=NULL, type="source")
Here is the error:
ERROR: dependencies ‘fBasics’, ‘fNonlinear’, ‘fGarch’, ‘fUtilities’, ‘tsDyn’, ‘tseriesChaos’ are not available for package ‘autots’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/autots’
Warning in install.packages :
installation of package ‘/Users/Mary/Downloads/autots_2.3.3.tar.gz’ had non-zero exit status

How do I install R packages on the SageMaker Notebook instance?

I tried to start a R notebook in Sagemaker and I typed
install.packages("disk.frame")
and it gave me the error
also installing the dependencies ‘listenv’, ‘dplyr’, ‘rlang’, ‘furrr’,
‘future.apply’, ‘fs’, ‘pryr’, ‘fst’, ‘globals’, ‘future’
Warning message in install.packages("disk.frame"):
“installation of package ‘rlang’ had non-zero exit status”
Warning message in install.packages("disk.frame"):
“installation of package ‘fs’ had non-zero exit status”
Warning message in install.packages("disk.frame"):
“installation of package ‘pryr’ had non-zero exit status”
Warning message in install.packages("disk.frame"):
“installation of package ‘fst’ had non-zero exit status”
Warning message in install.packages("disk.frame"):
“installation of package ‘dplyr’ had non-zero exit status”
Warning message in install.packages("disk.frame"):
“installation of package ‘disk.frame’ had non-zero exit status”
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
How do I install R packages on Sagemaker?
Thank you for using Amazon SageMaker.
This issue has been resolved and you should be able to install R packages using
install.packages("disk.frame")
or
install.packages("disk.frame", repo="https://cran.rstudio.com/")
I tested it and was able to successfully install the package with ouput
also installing the dependencies ‘listenv’, ‘benchmarkmeData’, ‘doParallel’, ‘bigassertr’, ‘bit’, ‘dplyr’, ‘rlang’, ‘furrr’, ‘future.apply’, ‘fs’, ‘pryr’, ‘fst’, ‘globals’, ‘future’, ‘benchmarkme’, ‘bigreadr’, ‘bit64’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
I think you just need to specify a repo. For example, setting the RStudio CRAN repo, I can install perfectly fine.
install.packages("disk.frame", repo="https://cran.rstudio.com/")
I have been getting the same error installing odbc on a sagemaker instance. I've tryed
remotes::install_github()
or
devtools::install_github()
and also:
install.packages('odbc', repo="https://cran.rstudio.com/")
and pretty much on every instance I get the same warning
“installation of package ‘odbc’ had non-zero exit status”Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
and if I try to call the package:
Error in library(odbc): there is no package called ‘odbc’
Traceback:
library(odbc)
I followed the instruction:
https://aws.amazon.com/blogs/machine-learning/creating-a-persistent-custom-r-environment-for-amazon-sagemaker/
And this code worked for me
system("conda install -n R -c conda-forge r-rjava")
Where r-rjava is the package name from Anaconda cloud. You can find the specific package name/version here: https://anaconda.org/
In SageMaker, click "File" > "New" > "Terminal".
In that terminal type conda install -c conda-forge r-disk.frame and push the Enter key.
If you need to install other R packages on SageMaker, search for them on https://anaconda.org/ where it will show you what to enter in the Terminal to download.
if you are still running in to the error, I found a way to get around it. Is very simple. I answered it in this other post, which I had already created. Sorry 'bout that:
Error installing RODBC or ODBC on a Sagemaker Jupyter NoteBook Instance

Error in library("Hmisc"): there is no package called 'Hmisc'

I just installed R using anaconda, and I am following this tutorial:
https://www.analyticsvidhya.com/blog/2016/03/tutorial-powerful-packages-imputing-missing-values/
I learned that I need to install some package by using:
if(!require(Hmisc)) install.packages("Hmisc",repos = "http://cran.us.r-project.org")
There are some warning message i am not sure whether it means successful or not:
Loading required package: Hmisc
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called 'Hmisc'also installing the dependencies 'survival', 'ggplot2'
Warning message:
In install.packages("Hmisc", repos = "http://cran.us.r-project.org"): installation of package 'survival' had non-zero exit status
Warning message:
In install.packages("Hmisc", repos = "http://cran.us.r-project.org"): installation of package 'ggplot2' had non-zero exit status
Warning message:
In install.packages("Hmisc", repos = "http://cran.us.r-project.org"): installation of package 'Hmisc' had non-zero exit status
The downloaded source packages are in
'/tmp/Rtmpcf6rZ9/downloaded_packages'
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Then I tried to load the library with
library(Hmisc)
But I got the error,
Error in library(Hmisc): there is no package called 'Hmisc'
Does anyone know what might has happened? Thanks.
Edit:
I am suggested to try a few more ways, but they all have various error:
install.packages("Hmisc")
Error in contrib.url(repos, type): trying to use CRAN without setting a mirror
If I do:
install.packages("Hmisc",repos = "http://cran.us.r-project.org")
I got:
also installing the dependencies 'survival', 'ggplot2'
Warning message:
In install.packages("Hmisc", repos = "http://cran.us.r-project.org"): installation of package 'survival' had non-zero exit status
Warning message:
In install.packages("Hmisc", repos = "http://cran.us.r-project.org"): installation of package 'ggplot2' had non-zero exit status
Warning message:
In install.packages("Hmisc", repos = "http://cran.us.r-project.org"): installation of package 'Hmisc' had non-zero exit status
The downloaded source packages are in
'/tmp/Rtmpcf6rZ9/downloaded_packages'
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
I am suggested not to use Anaconda R, but because I mostly use rpy2 and jupiter notebook the most. I think using the Anaconda R may be the most straight forward method to get my jupiter notebook and python to work seamlessly with R.
I had a similar issue, solved it by installing "acepack" directly install.packages('acepack')
This is mysterious, regardless. I do an update of all packages in Conda. Then, I install Rstudio using anaconda. Then the error does not exist anymore...

Cannot install any R packages?

I am using R 3.2.2 on a UNIX server (this is installed to my HOME).
Any package that I try to install returns an error message like this:
install.packages('knitr')
Warning: unable to access index for repository
https://cran.rstudio.com/src/contrib
Warning message:
package ‘knitr’ is not available (for R version 3.2.2)
I've also tried downloading the package source and installing manually, but that doesn't work:
install.packages('/home/baker/knitr_1.11.tar.gz',repos= NULL,type='source')
ERROR: dependencies ‘evaluate’, ‘digest’, ‘formatR’, ‘highr’, ‘markdown’, ‘stringr’, ‘yaml’ are not available for package ‘knitr’
* removing ‘/home/baker/R/lib64/R/library/knitr’
Warning message:
In install.packages("/home/baker/knitr_1.11.tar.gz", repos = NULL, :
installation of package ‘/home/baker/knitr_1.11.tar.gz’ had non-zero exit status
This is obviously a super frustrating problem...any ideas? I'm at a total loss.

Resources