Install R package in Jupyter - r

I have been trying over the weekend to install mosaic, car and some other packages on an R kernel (3.4.2) in Jupyter Notebook running Ubuntu 16.04. I have tried install.packages('car', '/home/jayaramdas/anaconda3/lib/R/library/', repos='http://cran.us.r-project.org'): it returns:
also installing the dependency ‘pbkrtest’
Warning message in install.packages("car", "/home/jayaramdas/anaconda3/lib/R/library/", :
“installation of package ‘pbkrtest’ had non-zero exit status”Warning message in install.packages("car", "/home/jayaramdas/anaconda3/lib/R/library/", :
“installation of package ‘car’ had non-zero exit status”
I've tried installing it in the original R package and I get this:
Warning messages:
1: In install.packages("car", "/home/jayaramdas/anaconda3/lib/R/library/", :
installation of package ‘pbkrtest’ had non-zero exit status
2: In install.packages("car", "/home/jayaramdas/anaconda3/lib/R/library/", :
installation of package ‘car’ had non-zero exit status
I tried using Rstudio to install it, but it won't let me write the file. I also tried downloading the zip file for Ubuntu and it still gave the 'non-zero exiterror. Is this a usual problem that people have withcar` and other R packages? I am just trying to figure how to add some packages to my jupyter notebook.

You are on Ubuntu. You want to use a package manager (conda).
May I suggest you use the native one?
sudo apt-get install r-cran-car
will install car and all its dependencies. If not, file an Ubuntu bug report.
Similarly, you can get many more packages from Ubuntu: apt-cache search 'r-cran-*'. And once you consider the Rutter PPAs you have a large part of CRAN prebuilt.

Related

Trying to get Tidyverse installed in Linux mint 20.2

I've been working on getting RStudio to open on and off for the last few days, finally got it running and started installing packages. Readr installed fine but tidyverse refuses to install.
/usr/bin/ld: /usr/local/lib/libcrypto.a(v3_genn.o): relocation R_X86_64_PC32 against symbol `GENERAL_NAME_it' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:6: openssl.so] Error 1
ERROR: compilation failed for package ‘openssl’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/openssl’
Warning in install.packages :
installation of package ‘openssl’ had non-zero exit status
ERROR: dependency ‘openssl’ is not available for package ‘ids’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/ids’
Warning in install.packages :
installation of package ‘ids’ had non-zero exit status
ERROR: dependency ‘openssl’ is not available for package ‘httr’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/httr’
Warning in install.packages :
installation of package ‘httr’ had non-zero exit status
ERROR: dependency ‘httr’ is not available for package ‘gargle’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/gargle’
Warning in install.packages :
installation of package ‘gargle’ had non-zero exit status
ERROR: dependency ‘httr’ is not available for package ‘rvest’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/rvest’
Warning in install.packages :
installation of package ‘rvest’ had non-zero exit status
ERROR: dependencies ‘gargle’, ‘httr’ are not available for package ‘googledrive’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/googledrive’
Warning in install.packages :
installation of package ‘googledrive’ had non-zero exit status
ERROR: dependencies ‘gargle’, ‘googledrive’, ‘httr’, ‘ids’ are not available for package ‘googlesheets4’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/googlesheets4’
Warning in install.packages :
installation of package ‘googlesheets4’ had non-zero exit status
ERROR: dependencies ‘googledrive’, ‘googlesheets4’, ‘httr’, ‘rvest’ are not available for package ‘tidyverse’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/tidyverse’
Warning in install.packages :
installation of package ‘tidyverse’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpyoCTNu/downloaded_packages’
To fix this I've tried suggestions from two places:
The first option was 'sudo apt install libcurl4-openssl-dev libssl-dev libxml2-dev'
from this website: https://blog.zenggyu.com/en/post/2018-01-29/installing-r-r-packages-e-g-tidyverse-and-rstudio-on-ubuntu-linux/
The second this was 'sudo apt-get install r-base-dev xml2 libxml2-dev libssl-dev libcurl4-openssl-dev unixodbc-dev'
from the rstudio community page: https://community.rstudio.com/t/cant-install-tidyverse/29293
A third option I found that is too advanced for me without guidance is this:
If openssl is already installed, check that 'pkg-config' is in your PATH and
PKG_CONFIG_PATH contains a openssl.pc file. If pkg-config is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
I'm sure I'm doing something wrong. I think something may not be in the proper place or is linked to the wrong location. Any assistance would be greatly appreciated.
(Also,for reference, this is the first time I've used linux so please dumb answers down as much as possible)
I've now gotten this to work. By looking at the error messages I found the dependencies that need to be installed before tidyverse can be installed (and function).
It is preferable but not necessary to get the latest version of R installed. I followed the steps in this tutorial:
https://linuxconfig.org/how-to-install-rstudio-on-ubuntu-20-04-focal-fossa-linux
In the interest of putting everything in one place, I'll put the steps here:
Step 1:
$ sudo apt update
$ sudo apt -y install r-base gdebi-core
Step 2: Install Rstudio from their website
Step 3: For this step, make sure you're in the folder that has the file downloaded, for me that was in downloads
$ sudo gdebi rstudio-1.2.5019-amd64.deb
Step 4: Open Rstudio
To get tidyverse to work, my error messages were all about non-zero exit statuses. What I did was to go through, find the packages that weren't properly installing, and manually install them.
My first problem was with curl. I tried installing it in Rstudio first. When I got an error, I went into terminal and installed it with
sudo apt-get install libcurl4-openssl-dev
If openssl refuses to install try:
sudo apt-get install libssl-dev
I tried installing tidyverse again, no dice. It was still having trouble with xml2 and rvest. I installed xml2 in terminal with.
sudo apt-get install libxml2-dev
After that, rvest installed using Rstudio and tidyverse installed successfully.
These instructions work with both R 4.1.1 and R 3.4.4
It would seem that the R version here is quite old, version 3.6. A bunch of things that are tidyverse related broke around the switch from 3.* to 4.*.
If you follow a procedure like this, it should get you started on the right path with the proper R version and the rest will likely fall into place.
https://linuxize.com/post/how-to-install-r-on-ubuntu-20-04/
Occasionally, on linux machines, you will have packages that fail to install because of system level dependencies that are missing. Those messages are usually informative; they will tell you what you need and the command for acquiring it.

install daewr package in R 4.0

hi i am trying to install package for experiment designs like this
install.packages("daewr", dependencies = T)
but it returns the following
configure: error: GNU MP not found, or not 4.1.4 or up, see http://gmplib.org
ERROR: configuration failed for package ‘gmp’
* removing ‘/home/yeferson/R/x86_64-pc-linux-gnu-library/4.0/gmp’
Warning in install.packages :
installation of package ‘gmp’ had non-zero exit status
ERROR: dependency ‘gmp’ is not available for package ‘partitions’
* removing ‘/home/yeferson/R/x86_64-pc-linux-gnu-library/4.0/partitions’
Warning in install.packages :
installation of package ‘partitions’ had non-zero exit status
ERROR: dependency ‘partitions’ is not available for package ‘DoE.base’
* removing ‘/home/yeferson/R/x86_64-pc-linux-gnu-library/4.0/DoE.base’
Warning in install.packages :
installation of package ‘DoE.base’ had non-zero exit status
ERROR: dependency ‘DoE.base’ is not available for package ‘FrF2’
* removing ‘/home/yeferson/R/x86_64-pc-linux-gnu-library/4.0/FrF2’
Warning in install.packages :
installation of package ‘FrF2’ had non-zero exit status
ERROR: dependency ‘FrF2’ is not available for package ‘daewr’
* removing ‘/home/yeferson/R/x86_64-pc-linux-gnu-library/4.0/daewr’
Warning in install.packages :
installation of package ‘daewr’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpB1bSe0/downloaded_packages’
so i decided to download the file from https://cran.r-project.org/web/packages/daewr/index.html
after trying to install it returns me
also installing the dependencies ‘gmp’, ‘partitions’, ‘DoE.base’, ‘FrF2.catlg128’
I try to install the first one but it asks for a Bessel package and it still gives me problems
I solved it by installing dependency one by one, many answer you install the dependencies but they do not say how I will explain them for the new ones in linux and in R to install the daerw package with the aforementioned problems, install the following in the linux console
sudo apt-get install libgsl-dev
with that install libraries now I can open R and install
install.packages('gsl')
then I opened the linux console again and installed
sudo apt-get install libgmp-dev
I go back to R and install
install.packages("gmp", dependencies = T)
now I can install the package without problems
install.packages("daewr", dependencies = T)
library(daewr)
I hope that any comment is welcome.

Non-zero exit status in R Jupyter Notebook but not in R

I am receiving a non-zero exit status when trying to install ggpubr in my R Jupyter Notebook. I was having this same issue about 2 weeks ago when trying to install gglot2, which I kept fumbling around including changing the CRAN and the package eventually installed.
I think there may be an issue at installing the dependencies in Jupyter notebook. I went back to the previous notebook where I installed ggplot2 and tried to run that code to see whether ggplot2 would reinstall--it doesn't and now that also returns non-zero exit status. I don't understand why I was once able to eventually install ggplot2 and I no longer can and I cannot install ggpubr either.
Note I've been able to install both ggplot2 and ggpubr in R, so I think this may be a Jupyter Notebook issue. I am an absolute beginner with coding, so any help with this and advice is much appreciated!!
Using macOS Mojave 10.14.6
install.packages("ggpubr")
also installing the dependencies ‘nloptr’, ‘pbkrtest’, ‘lme4’, ‘car’, ‘rstatix’
Warning message in install.packages("ggpubr"): “installation of package ‘nloptr’ had non-zero exit status”
Warning message in install.packages("ggpubr"): “installation of package ‘lme4’ had non-zero exit status”
Warning message in install.packages("ggpubr"): “installation of package ‘pbkrtest’ had non-zero exit status”
Warning message in install.packages("ggpubr"): “installation of package ‘car’ had non-zero exit status”
Warning message in install.packages("ggpubr"): “installation of package ‘rstatix’ had non-zero exit status”
Warning message in install.packages("ggpubr"): “installation of package ‘ggpubr’ had non-zero exit status”
Updating HTML index of packages in '.Library' Making 'packages.html'
...done
I kept getting the non-zero exit status when trying to install packages with Jupyter notebook with R kernel and was failing because of multiple dependencies when wanting to install a package. I am not an expert in any of these so please forgive me if I make an error in explaining or if it is a non-issue for you but please feel free to comment to clear things out. I just want to share my success story so hopefully it can help someone else:
I am working on a MacBook Pro. Here are the information I get when I run R.version() on my jupyter notebook with R kernel:
$platform 'x86_64-conda_cos6-linux-gnu'
$arch 'x86_64'
$os 'linux-gnu'
$system 'x86_64, linux-gnu'
$language 'R'
$version.string 'R version 3.6.1 (2019-07-05)'
These are the steps to take to fix the issue:
Go to https://anaconda.org/
Search the package name that you are trying to install
Copy the one line that is given to install the package, it should be something like:
Conda install -c r r-caret
#conda install -c r r-package_name
NOTE: sometimes during installing packages, you’re asked whether or not you want to continue, so add --y at the end of the above statement to continue, so something like this
Conda install -c r r-caret --y (I will always add it just to be on the safe side)
Click on the new launcher (+ icon) to create a new notebook with PySpark (once opened it has .ipynp extension)
On the first cell paste the copied line from step 3 and run
Once done, restart the kernel on the current notebook
Restart the kernel on your other notebook with R kernel
Run library (package_name) on your notebook with R kernel (e.x. library(caret))

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

How to fix 'libproj not found in standard or given locations' error in r

I'm trying to install the 'agricolae' package on R, but I get an error saying
configure: error: libproj not found in standard or given locations.
ERROR: configuration failed for package ‘sf’
* removing ‘/R/x86_64-pc-linux-gnu-library/3.6/sf’
Warning in install.packages :
installation of package ‘sf’ had non-zero exit status
ERROR: dependency ‘sf’ is not available for package ‘spdep’
* removing ‘/R/x86_64-pc-linux-gnu-library/3.6/spdep’
Warning in install.packages :
installation of package ‘spdep’ had non-zero exit status
ERROR: dependency ‘spdep’ is not available for package ‘agricolae’
* removing ‘/R/x86_64-pc-linux-gnu-library/3.6/agricolae’
Warning in install.packages :
installation of package ‘agricolae’ had non-zero exit status
I recently upgraded to Ubuntu 18.04.2 and R version 3.6.0 (2019-04-26) -- "Planting of a Tree" and that's when the problems started.
When I do
$ sudo apt-get install -y libproj-dev
I get:
libproj-dev is already the newest version (5.2.0-1~bionic0).
The error says that package 'sf' is not available for dependency 'spdep'. So you should be attempting to install pkg 'sf'. (I'm on the same OS as you and pkg:agricolae installed without problem just now. I have a more complete set of spatial R and system packages than you do.)
Edit: There have been reports that it was necessary in addressing this problem to create an environment link to the location of your libraries:
$ export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
(From: https://stat.ethz.ch/pipermail/r-sig-geo/2018-August/026740.html which in turn linked to https://gis.stackexchange.com/questions/157059/repairing-broken-gdal-and-proj-4-on-ubuntu, which has so further debugging options mentioned.)

Resources