Installing "choroplethr" in Ubuntu - r

I am trying to install "choroplethr."
I have read the following related-looking errors:
https://askubuntu.com/questions/1057100/error-libudunits2-a-not-found-when-installing-ggraph-additional-error-objec
Install udunits2 package for R3.3
Their recommendation is to install something I have already installed. I have libudunits2 installed in a standard location, with:
$ sudo apt-get install libudunits2-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libudunits2-dev is already the newest version (2.2.26-1).
I can see headers:
$ ll /usr/include/ | grep unit
-rw-r--r-- 1 root root 39998 Jan 5 2018 udunits2.h
-rw-r--r-- 1 root root 5195 Jan 5 2018 udunits.h
However, on installation, I get this error:
$ R
R version 3.5.1 (2018-07-02) -- "Feather Spray"
> install.package("choroplethr", dep=T)
...
configure: error: in `/tmp/RtmpWC06JV/R.INSTALL7cbb4928db67/units':
configure: error:
--------------------------------------------------------------------------------
Configuration failed because libudunits2.so was not found. Try installing:
* deb: libudunits2-dev (Debian, Ubuntu, ...)
* rpm: udunits2-devel (Fedora, EPEL, ...)
* brew: udunits (OSX)
If udunits2 is already installed in a non-standard location, use:
--configure-args='--with-udunits2-lib=/usr/local/lib'
if the library was not found, and/or:
--configure-args='--with-udunits2-include=/usr/include/udunits2'
if the header was not found, replacing paths with appropriate values.
You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
--------------------------------------------------------------------------------
I've done these settings, but
install.packages("udunits2", configure.args = '--with-udunits2-include=/usr/include/udunits2')
-----Error: libudunits2.a not found-----
If the udunits2 library is installed in a non-standard location,
use --configure-args='--with-udunits2-lib=/usr/local/lib' for example,
or --configure-args='--with-udunits2-include=/usr/include/udunits2'
replacing paths with appropriate values for your installation.
You can alternatively use the UDUNITS2_INCLUDE and UDUNITS2_LIB
environment variables.
If udunits2 is not installed, please install it.
It is required for this package.
What am I missing? Is this package OSX only?

For Ubuntu with R 3.5 you can use the c2d4u3.5 PPA made available by the same persons that bring you R Ubuntu packages on CRAN, c.f. https://cran.r-project.org/bin/linux/ubuntu/README.html and http://dirk.eddelbuettel.com/blog/2017/12/22/:
sudo add-apt-repository ppa:marutter/c2d4u3.5
sudo apt-get update
After that you can install binary packages for most CRAN packages:
sudo apt-get install r-cran-choroplethr
This should work for all packages that are mentioned in CRAN task views.
Besides this, I tried to reproduce your installation problems using docker:
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install --yes --no-install-recommends gnupg ca-certificates \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \
&& echo "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get install --yes --no-install-recommends r-base-dev libudunits2-dev \
&& Rscript -e 'install.packages(c("units", "udunits2"))'
However, the image was build without problems.

Related

Installing R 4.0.3 on Raspberry Pi 4 with Ubuntu 20.10

I am trying to install R 4.0.3 on a Raspberry Pi 4 running Ubuntu 20.10 64-bit. It is fully updated.
Before I did anything, I added the correct CRAN repository for this OS using sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu groovy-cran40/'.
When I run sudo apt install r-base, I get an error that r-base-core and r-recommendrf, both of which are specified to require version >= 4.0.3-1.2010.0, are "not going to be installed".
Checking them individually, it seems that r-base-core is the problem. If I try to install r-recommended by itself, I get an error that it needs "r-base-core (>= 4.0.3-1.2010.0) but 4.0.2-1build1 is to be installed".
If I check https://cloud.r-project.org/bin/linux/ubuntu/groovy-cran40/, I notice that r-base-core 4.0.3 is only available in an AMD64 variant, per the amd64 in the filenames. I observe that the r-base package's files do not have amd64 in their filenames. To me, that suggests that, currently, you're only running R 4.0.3 on Ubuntu 20.10 if you are on an Intel/AMD 64-bit platform. https://cloud.r-project.org/bin/linux/ubuntu/groovy-cran40/Packages seems to back that up.
Are there practical alternatives, other than to wait for an r-base-core 4.0.3 package to appear that is compatible with more platforms?
Found the answer. Most of the credit goes to Andrés Castro Socolich, who provided most of the solution.
This assumes a mostly vanilla Raspberry Pi 4 with Ubuntu 20.10 64-bit installed:
sudo apt update
sudo apt ugrade
sudo apt-get install -y g++ gfortran libreadline6-dev libx11-dev libxt-dev libpng-dev libjpeg-dev libcairo2-dev xvfb libbz2-dev libzstd-dev liblzma-dev libcurl4-openssl-dev texinfo texlive texlive-fonts-extra screen wget libpcre2-dev zlib1g-dev libbz2-dev liblzma-dev libpcre2-dev libcurl4-openssl-dev openjdk-11-jdk make
cd /usr/local/src
sudo wget https://cran.rstudio.com/src/base/R-4/R-4.0.3.tar.gz
sudo su
tar zxvf R-4.0.3.tar.gz
cd R-4.0.3
./configure --enable-R-shlib
make
make install
cd ..
rm -rf R-4.0.3*
exit
cd

shiny docker image build failed due to ubuntu package issue

I'm trying to build docker image for my R shiny app. Below is theDockerfile.
# Install R version 3.6
FROM r-base:3.6.0
# Install Ubuntu packages
RUN apt-get update && apt-get install -y \
sudo \
gdebi-core \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev \
libxt-dev \
xtail \
wget \
libudunits2-dev \
libgdal-dev
# Install R packages that are required
RUN R -e "install.packages(c('remotes', 'tidyr', 'dplyr', 'ggplot2', 'stringr','shiny', 'shinydashboard','shinyWidgets','shinyjs', 'rlang','scales','DT','lubridate', 'plotly', 'leaflet', 'leafpop', 'visNetwork', 'wordcloud2', 'arules'), repos='http://cran.rstudio.com/')"
RUN R -e "remotes::install_github('nik01010/dashboardthemes')"
# Download and install ShinyServer (latest version)
RUN wget --no-verbose https://download3.rstudio.org/ubuntu-14.04/x86_64/VERSION -O "version.txt" && \
VERSION=$(cat version.txt) && \
wget --no-verbose "https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-$VERSION-amd64.deb" -O ss-latest.deb && \
gdebi -n ss-latest.deb && \
rm -f version.txt ss-latest.deb
# Copy configuration files into the Docker image
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf
COPY /app /srv/shiny-server/
# Make the ShinyApp available at port 80
EXPOSE 80
# Copy further configuration files into the Docker image
COPY shiny-server.sh /usr/bin/shiny-server.sh
CMD ["/usr/bin/shiny-server.sh"]
However, my image building failed quite early. Below is all the logs. It seems like some Ubuntu package issue which I do not quite understand.
I'm new to docker. I have not clue what to do with those error messages. Appreciate if anyone can help find out what needs to be done. Thanks.
Sending build context to Docker daemon 113.4MB
Step 1/10 : FROM r-base:3.6.0
---> 876f4d7b60e9
Step 2/10 : RUN apt-get update && apt-get install -y sudo gdebi-core pandoc pandoc-citeproc libcurl4-gnutls-dev libcairo2-dev libxt-dev xtail wget libudunits2-dev libgdal-dev
---> Running in 825a69c5a05f
Get:2 http://deb.debian.org/debian testing InRelease [116 kB]
Get:1 http://cdn-fastly.deb.debian.org/debian sid InRelease [146 kB]
Get:3 http://deb.debian.org/debian testing/main amd64 Packages [7,690 kB]
Get:4 http://cdn-fastly.deb.debian.org/debian sid/main amd64 Packages [8,225 kB]
Fetched 16.2 MB in 6s (2,724 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libc6-dev : Breaks: libgcc-8-dev (< 8.4.0-2~) but 8.3.0-7 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
The command '/bin/sh -c apt-get update && apt-get install -y sudo gdebi-core pandoc pandoc-citeproc libcurl4-gnutls-dev libcairo2-dev libxt-dev xtail wget libudunits2-dev libgdal-dev' returned a non-zero code: 100
The error message you are receiving is not Docker specific, but rather concerns your package manager apt.
Although you are updating the package list using apt-get update, you do not install newer versions of packages. What happens now is that you are trying to install a newer version of an already installed package which leads to the error message.
If you use apt-get upgrade, apt will install the newer versions of your installed packages.
Changing the 5th line as shown below will fix that issue:
RUN apt-get update && apt-get upgrade -y && apt-get install -y \

Update R in ubuntu

I'm having some problems to update my R in my ubuntu. When I try I get this message:
sudo apt-get install r-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
r-base : Depends: r-base-core (>= 4.0.0-1.1804.0) but 3.6.3-1eoan is to be installed
Depends: r-recommended (= 4.0.0-1.1804.0) but 3.6.3-1eoan is to be installed
E: Unable to correct problems, you have held broken packages.
When I ran: apt policy r-base i've got this message:
apt policy r-base
r-base:
Installed: 3.6.3-1eoan
Candidate: 4.0.0-1.1804.0
Version table:
4.0.0-1.1804.0 500
500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
*** 3.6.3-1eoan 100
100 /var/lib/dpkg/status
3.6.1-4 500
500 http://br.archive.ubuntu.com/ubuntu eoan/universe amd64 Packages
500 http://br.archive.ubuntu.com/ubuntu eoan/universe i386 Packages
I've already changed my source list puting this inside:
https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/
Does anyone know what do I do to resolve this problem?
Browse to /etc/apt/sources.list and check if you have added the correct repo.
Remove any old CRAN mirror like bionic-cran35.
If you haven't properly added the current CRAN mirror, run these commands:
(you can confirm the GPG key here: https://cran.r-project.org/bin/linux/ubuntu/README.html):
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/"
Then fix remaining problems and update (which might already solve the issue):
sudo apt --fix-broken install
sudo apt autoremove
sudo apt update
sudo apt upgrade
Remove current version of r and dependencies:
sudo apt remove r-base-core
sudo apt remove r-recommended
sudo apt remove r-base
Install the newest r-base:
sudo apt install r-base
To check your success, run this code:
R
version

How to build Dockerfile with R & Java

I'm trying to build a Docker container that runs R with the package RJava. I have tried the following code:
# Install R version 3.6.3
FROM rocker/tidyverse:3.6.3
# Make ~/.R
RUN mkdir -p $HOME/.R
# Install Ubuntu packages && then R packages
RUN install2.r --error \
lubridate magrittr RPostgres DBI broom rlang rJava
However I get the following: installation of package ‘rJava’ had non-zero exit status.
Can anyone help me with this. I'm thinking that maybe it is because Java is not installed. Does anyone know how to install Java on this docker container?
I've tried adding the following to my dockerfile as per another post I found however I get the error saying 'The repository 'http://ppa.launchpad.net/webupd8team/java/ubuntu focal Release' does not have a Release file:
# Install "software-properties-common" (for the "add-apt-repository")
RUN apt-get update && apt-get install -y \
software-properties-common
# Add the "JAVA" ppa
RUN add-apt-repository -y \
ppa:webupd8team/java
# Install OpenJDK-8
RUN apt-get update && \
apt-get install -y openjdk-8-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
I'm new to docker and any help with this would be much appreciated.
The rocker images are based on debian, not ubuntu. Specifically it is Debian GNU/Linux 10 (buster). With that version, you can install java by installing the package openjdk-11-jdk via apt and you don't need to add any repositories for openjdk-8-jdk.
So a working dockerfile that installs rJava:
FROM rocker/tidyverse:3.6.3
RUN apt-get update && \
apt-get install -y openjdk-11-jdk && \
apt-get install -y liblzma-dev && \
apt-get install -y libbz2-dev
RUN Rscript -e "install.packages('rJava')"
Note: liblzma-dev and libbz2-dev are additional system dependencies for compiling rJava.

Installing R devtools package on WSL

The problem:
I'm trying to install the devtools package for R. I'm using Ubuntu 18.04 LTS on WSL, the Windows Subsystem for Linux.
I'm able to install some packages just fine with a simple call to install.packages() from within R on WSL. However, other packages seem to give me trouble.
None of the following methods I've tried seem to work:
* I've tried installing the package with install.packages().
* I've tried installing from source into /usr/local/lib/R/site-library.
* I've tried installing from source into a personal library.
Error message:
I was recieving an error message like that discussed here, but I was unable to fix the problem by editing unpackPkgZip because it didn't exist.
The Question:
How can I install devtools on WSL?
Solution:
I was able to fix the problem by starting over. I uninstalled Ubuntu and then reinstalled it. With a fresh install of Ubuntu 18.04 I followed these instructions. There are other online tutorials which probably work just fine, but I followed this one. You can ignore the bit about installing an rstudio server and the fsl package if you wish.
# Install R on WSL
sudo apt-get update -qq -y
sudo apt-get install -y wget git
OS_DISTRIBUTION=$(lsb_release -cs)
wget -O- http://neuro.debian.net/lists/${OS_DISTRIBUTION}.us-nh.full | sudo tee /etc/apt/sources.list.d/neurodebian.sources.list
sudo apt-key adv --recv-keys --keyserver hkp://pool.sks-keyservers.net:80 0xA5D32F012649A5A9
sudo apt-get update
sudo apt-get install libopenblas-base r-base
sudo apt-get update -qq -y
sudo apt-get install -y libgit2-dev
sudo apt-get install -y libcurl4-openssl-dev libssl-dev
sudo apt-get install -y zlib1g-dev libssh2-1-dev libpq-dev libxml2-dev
#sudo apt-get install -y libhdf5 # This didn't work.
Now try installing devtools in R.
# Install devtools
install.packages("devtools", repos = "https://cran.rstudio.com/")
Permission error:
If you encounter a permission error like the following...
Warning in install.packages("edgeR") :'lib = "/usr/local/lib/R/site-library"' is not writable Would you like to use a personal library instead? (y/n)
...you need to provide the user with write access to the directory where R packages are installed (see here). Try changing the group ownership of this directory:
# Who has ownership of /usr/local/lib/R/site-library/?
ls -l /usr/local/lib/R/
# drwxrwsr-x 1 root staff 512 Jul 18 21:38 site-library
# Change ownership.
sudo chgrp twesleyb /usr/local/lib/R/site-library/
ls -l /usr/local/lib/R/
#drwxrwxr-x 1 root twesleyb 512 Jul 18 21:38 site-library
# In this case I have write access, but in case you need to add it, try:
# $ sudo chmod g+w /usr/local/lib/R/site-library
You should now be able to install.packages("package").
I'm a linux novice, but I think this is an okay thing to do.
Update:
You can also try following duckmayr's instructions.

Resources