Seite 1 von 2

[gelöst] R unter Linux - Pakete laden

Verfasst: Fr Aug 31, 2018 6:45 pm
von Hufeisen
Hallo alle,

vorweg als Hintergrundinformation: Mein Windowsrechner ist nach acht Jahren seinen seeligen Tod gestorben. Als Ersatz dient ein Notebook mit Ryzenprozessor. Dieser wird von Windows 7 nicht mehr unterstützt. Die späteren Windowsversionen möchte ich aber wegen ihrer unsäglichen Spioniererei nicht nutzen. Deshalb migriere ich nun den letzten Rechner in unserem Haushalt, eben mein Arbeitsgerät, auch auf Linux.

Ich habe große Probleme R auf meinem Rechner vernünftig zum Laufen zu bringen. Zunächst habe ich versucht, im Linux Mint Forum Hilfe zu bekommen, dort ist R aber wohl nicht bekannt genug. Der Thread ist hier:
Ich nutze Linux Mint 19 Cinnamon. R liegt in der Version 3.4.4 vor und ließ sich problemlos installieren.

Code: Alles auswählen

R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
Auch RStudio habe ich installiert, aktuell aber wieder entfernt, um die Fehlersuche einzugrenzen.
R läuft problemlos in seiner Basisausstattung. Beim Laden von Paketen scheitere ich aber gewaltig. Aktuell orientiere ich mich bei der Installation von R (später dann RStudio) und Paketen an diesen Anleitungen
https://linuxconfig.org/install-r-on-ub ... aver-linux
https://linuxconfig.org/rstudio-on-ubun ... aver-linux
https://linuxconfig.org/how-to-install- ... s-in-gnu-r

Nach dieser Anleitung (dem dritten Link) installiert man Pakete in R, die nicht in den Ubuntu-Repositories enthalten sind, über einen externen Link, den man mit wget abruft und mit R CMD INSTALL die geladene Datei installiert.
wget - geht

Code: Alles auswählen

mp@Gert:~$ wget https://cran.r-project.org/src/contrib/tmap_2.1-1.tar.gz
--2018-08-31 18:10:55--  https://cran.r-project.org/src/contrib/tmap_2.1-1.tar.gz
Auflösen des Hostnamens cran.r-project.org (cran.r-project.org) … 137.208.57.37
Verbindungsaufbau zu cran.r-project.org (cran.r-project.org)|137.208.57.37|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: 3055403 (2,9M) [application/x-gzip]
Wird in »tmap_2.1-1.tar.gz« gespeichert.

tmap_2.1-1.tar.gz   100%[===================>]   2,91M  1,08MB/s    in 2,7s    

2018-08-31 18:10:58 (1,08 MB/s) - »tmap_2.1-1.tar.gz« gespeichert [3055403/3055403]
Installation - geht nicht, weil Abhängigkeiten fehlen

Code: Alles auswählen

 R CMD INSTALL tmap_2.1-1.tar.gz
* installing to library ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4’
ERROR: dependencies ‘tmaptools’, ‘sf’, ‘units’, ‘raster’, ‘leaflet’, ‘mapview’ are not available for package ‘tmap’
* removing ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4/tmap’
Aus der Anleitung: NOTE: Be aware that some packages will require prerequisites. In that case use the above command to install prerequisites prior to your desired package. Unter Windows installiert R ja einfach das Paket inklusive der Abhängigkeiten.
Ich brauche aktuell 7 Pakete, die zusammen wohl 100 Abhängigkeiten haben könnten. Die muss ich doch wohl nicht alle manuell im Internet suchen, herunterladen und installieren? Das kann doch nicht der Weg unter LInux sein?!

Die Installation aus R heraus dauert noch länger und gibt mehr Fehlermeldungen aus, die kann ich aber hier auch gerne zeigen. Ich danke für jede Hilfe.
Edit: Ich habe auch im Ubuntuforum gefragt, dort ist der Beitrag aber erstmal als spam gekennzeichnet.

Hufeisen

Re: R unter Linux - Pakete laden

Verfasst: Fr Aug 31, 2018 7:33 pm
von jogo
Hallo Hufeisen,

willkommen im Forum!
Ich arbeite seit etlichen Jahren mit R unter (oder sollte man nach dem Schichtenmodell besser über sagen) Linux. Um genau zu sein, verwende ich Ubuntu. Seit ich dort RStudio verwende ist alles enorm einfach - doch dazu später mehr.
Vor RStudio habe ich für das Installieren von zusätzlichen Paketen folgendes gemacht:
1. root-Shell besorgen mit sudo su
2. R aufrufen
3. von der R-Console die Funktion install.packages() aufrufen.
Oft genug kam dann die Meldung "Paket xxx benötigt vorher noch Paket yyy". Das kann man auch alles per Handarbeit lösen oder es gibt auch den Parameter dependencies=. Dieses händische Runterladen von Paketen habe ich ewig nicht gemacht.
Eher würde ich wahrscheinlich Sourcepackages verwenden - dann hat man auch die Anpassung an die aktuelle Maschine.
All dieses Gefummele ist hinfällig in RStudio - dort gibt es einen entsprechenden Menüpunkt.
Inzwischen weiß ich nichtmal mehr, ob RStudio beim Installieren der Pakete einen root-Modus verwendet (als Übernahme der Rechte aus der Installation von RStudio) oder ob die Pakete im user-Verzeichnis installiert werden, was ja auch problemlos möglich ist.

Gruß, Jörg

Re: R unter Linux - Pakete laden

Verfasst: Fr Aug 31, 2018 8:24 pm
von Hufeisen
Eben unser Baby ins Bett gebracht, ich hoffe mein Post ist trotzdem klar und verständlich.

Hallo Jörg,

das zu lesen, da fällt mir wahrlich ein Stein vom Herzen. sudo su und install.packages() kannte ich nicht, das ist ja schon sehr nett (die Leiste mit den Paketen zum auswählen kannte ich nicht). Ich muss vorweg sagen, ich bin in Linux noch nicht sattelfest. Ich habe in R jetzt testweise die Installation von ggplot2 angestoßen und es laufen Fehler auf.

Code: Alles auswählen

mp@Gert:~$ sudo su
[sudo] Passwort für mp: 
root@Gert:/home/mp# R
install.packages("ggplot2", dependencies = TRUE)

....

Die heruntergeladenen Quellpakete sind in 
	‘/tmp/RtmpHiSyfk/downloaded_packages’
Warnmeldungen:
1: In install.packages("ggplot2", dependencies = TRUE) :
  Installation des Pakets ‘gdtools’ hatte Exit-Status ungleich 0
2: In install.packages("ggplot2", dependencies = TRUE) :
  Installation des Pakets ‘units’ hatte Exit-Status ungleich 0
3: In install.packages("ggplot2", dependencies = TRUE) :
  Installation des Pakets ‘sf’ hatte Exit-Status ungleich 0
4: In install.packages("ggplot2", dependencies = TRUE) :
  Installation des Pakets ‘svglite’ hatte Exit-Status ungleich 0
5: In install.packages("ggplot2", dependencies = TRUE) :
  Installation des Pakets ‘vdiffr’ hatte Exit-Status ungleich 0
Ich weiß nicht was Sourcepackages sind, kann es mir aber denken - vollständige Pakete mit Abhängigkeiten.

Ich kann ja mal RStudio installieren und probieren, ob mein Skript dort läuft (was es bisher nicht tat). Um auf der sicheren Seite zu sein, kannst du mir verraten, wie ich RStudio richtig installiere. Bisher waren das bei mir eher workarounds - siehe https://www.linuxmintusers.de/index.php?topic=39788.0

Re: R unter Linux - Pakete laden

Verfasst: Fr Aug 31, 2018 9:53 pm
von Hufeisen
Ich habe die aktuelle Version von RStudio geladen (1.1.456) - über das Terminal geht es inzwischen (mp@Gert:~$ sudo dpkg -i /home/mp/Downloads/rstudio-xenial-1.1.456-amd64.deb).
Ich habe rstudio jetzt das erste mal über das Terminal gestartet und das gibt gleich interessante Fehler aus.

Code: Alles auswählen

mp@Gert:~$ rstudio
load glyph failed err=6 face=0x2904320, glyph=2798
load glyph failed err=6 face=0x2904320, glyph=2798
libpng warning: iCCP: known incorrect sRGB profile
^C
mp@Gert:~$ rstudio
load glyph failed err=6 face=0x1c36290, glyph=2798
load glyph failed err=6 face=0x1c36290, glyph=2798
Auch in RStudio gibt die Installation von ggplot2 Fehler aus

Code: Alles auswählen

> install.packages("ggplot2", dependencies = TRUE)
Installing package into ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependencies ‘gdtools’, ‘units’, ‘vdiffr’, ‘sf’, ‘svglite’

versuche URL 'https://cloud.r-project.org/src/contrib/gdtools_0.1.7.tar.gz'
Content type 'application/x-gzip' length 35268 bytes (34 KB)
==================================================
downloaded 34 KB

versuche URL 'https://cloud.r-project.org/src/contrib/units_0.6-0.tar.gz'
Content type 'application/x-gzip' length 912393 bytes (891 KB)
==================================================
downloaded 891 KB

versuche URL 'https://cloud.r-project.org/src/contrib/vdiffr_0.2.3.tar.gz'
Content type 'application/x-gzip' length 77057 bytes (75 KB)
==================================================
downloaded 75 KB

versuche URL 'https://cloud.r-project.org/src/contrib/sf_0.6-3.tar.gz'
Content type 'application/x-gzip' length 7973054 bytes (7.6 MB)
==================================================
downloaded 7.6 MB

versuche URL 'https://cloud.r-project.org/src/contrib/svglite_1.2.1.tar.gz'
Content type 'application/x-gzip' length 41315 bytes (40 KB)
==================================================
downloaded 40 KB

versuche URL 'https://cloud.r-project.org/src/contrib/ggplot2_3.0.0.tar.gz'
Content type 'application/x-gzip' length 2847050 bytes (2.7 MB)
==================================================
downloaded 2.7 MB

* installing *source* package ‘gdtools’ ...
** Paket ‘gdtools’ erfolgreich entpackt und MD5 Summen überprüft
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cairo' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lcairo
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because cairo was not found. Try installing:
 * deb: libcairo2-dev (Debian, Ubuntu)
 * rpm: cairo-devel (Fedora, CentOS, RHEL)
 * csw: libcairo_dev (Solaris)
 * brew: cairo (OSX)
If cairo is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a cairo.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=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘gdtools’
* removing ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4/gdtools’
Warning in install.packages :
  installation of package ‘gdtools’ had non-zero exit status
* installing *source* package ‘units’ ...
** Paket ‘units’ erfolgreich entpackt und MD5 Summen überprüft
configure: units: 0.6-0
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdbool.h that conforms to C99... no
checking for _Bool... no
checking for error_at_line... yes
checking for gcc... gcc -std=gnu99
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking for XML_ParserCreate in -lexpat... yes
checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking udunits2/udunits2.h usability... no
checking udunits2/udunits2.h presence... no
checking for udunits2/udunits2.h... no
checking for ut_read_xml in -ludunits2... no
configure: error: in `/tmp/RtmpLlcCyc/R.INSTALLc5d53bea1f1/units':
configure: error: 
--------------------------------------------------------------------------------
  libudunits2.so not found!

  If the udunits2 library is installed in a non-standard location, use:

    --configure-args='--with-udunits2-lib=/usr/local/lib'

  for example, 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 for your
  installation. You can alternatively use the UDUNITS2_INCLUDE and UDUNITS2_LIBS
  environment variables.

  If udunits2 is not installed, please install it.
  It is required for this package.
--------------------------------------------------------------------------------

See `config.log' for more details
ERROR: configuration failed for package ‘units’
* removing ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4/units’
Warning in install.packages :
  installation of package ‘units’ had non-zero exit status
* installing *source* package ‘ggplot2’ ...
** Paket ‘ggplot2’ erfolgreich entpackt und MD5 Summen überprüft
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (ggplot2)
ERROR: dependency ‘units’ is not available for package ‘sf’
* removing ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4/sf’
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status
ERROR: dependency ‘gdtools’ is not available for package ‘svglite’
* removing ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4/svglite’
Warning in install.packages :
  installation of package ‘svglite’ had non-zero exit status
ERROR: dependencies ‘gdtools’, ‘svglite’ are not available for package ‘vdiffr’
* removing ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4/vdiffr’
Warning in install.packages :
  installation of package ‘vdiffr’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/Rtmp9EluCm/downloaded_packages’
Edit: Ich werde morgen mal versuchen, die Meldungen XY fehlt abzuarbeiten.

Edit2: Edit1 erledigt, scheint langsam Fortschritte zu machen. ggplot2 wurde erfolgreich installiert.

Code: Alles auswählen

> install.packages("ggplot2", type = "source")
Installing package into ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
versuche URL 'https://cloud.r-project.org/src/contrib/ggplot2_3.0.0.tar.gz'
Content type 'application/x-gzip' length 2847050 bytes (2.7 MB)
==================================================
downloaded 2.7 MB

* installing *source* package ‘ggplot2’ ...
** Paket ‘ggplot2’ erfolgreich entpackt und MD5 Summen überprüft
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (ggplot2)

The downloaded source packages are in
	‘/tmp/RtmpFekpov/downloaded_packages’

Re: R unter Linux - Pakete laden

Verfasst: Sa Sep 01, 2018 8:19 am
von Hufeisen
Okay ich glaube, ich weiß jetzt, woran es liegt. Nachdem ich gestern aufbauend auf den Fehlermeldungen von R einige Pakete manuell nachgeladen habe, konnte ich ggplot2 laden. Weiterhin konnte ich nun problemlos "sp", "rgdal", "ncdf4", "rgeos", "ggrepel", "reshape2" und "Hmisc" laden. Bei meinem letzten benötigten Paket "tmap" kommen dann wieder Fehler über Fehler. Auf der Github-Seite für tmap steht in den Installationshinweisen (https://github.com/mtennekes/tmap#installation):
tmap is available on CRAN (version 2.1-1). Installation is straightforward:

install.packages("tmap")

However, for some operating systems require additional libraries. The installation procedure is as follows:

Windows No additional installation required.

Linux (Ubuntu) See installation script for Ubuntu 16 and 17/18. Please address intallation issues in the issue thread.

macOS See http://www.kyngchaos.com. Please address intallation issues in the issue thread.
Im LInuxscript steht dann eine Liste benötigter Pakete:
sudo apt-get install libgdal-dev
sudo apt-get install libgeos-dev
sudo apt-get install libproj-dev
sudo apt-get install libudunits2-dev
sudo apt-get install libv8-dev
sudo apt-get install libjq-dev
sudo apt-get install libprotobuf-dev
sudo apt-get install protobuf-compiler
sudo apt-get install libssl-dev
sudo apt-get install libcairo2-dev
Kennt ihr das so, kann man das aus RStudio heraus automatisch lösen?

Edit: Pakete per Terminal installiert, tmap geht immer noch nicht.

Code: Alles auswählen

install.packages("tmap", dependencies = TRUE)
Installing package into ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependencies ‘protolite’, ‘geojson’, ‘jqr’, ‘jsonvalidate’, ‘stars’, ‘geojsonio’, ‘geojsonlint’, ‘V8’, ‘tmaptools’, ‘mapview’, ‘lwgeom’, ‘rmapshaper’, ‘cartogram’

...
shared object ‘sf.so’ not found
Error : package ‘sf’ could not be loaded
Dazu gibt es (wenn ich das richtig sehe) vom Paketersteller einen Thread https://github.com/mtennekes/tmap/issues/150
Die Installation des Pakets liblwgeom-dev (Version 2.4.3 - holt das Terminal automatisch) schafft bei mir aber keine Abhilfe. Aktuell scheitert es an:

Code: Alles auswählen

lwgeom.cpp:2:10: fatal error: sf.h: Datei oder Verzeichnis nicht gefunden
 #include <sf.h>

Re: R unter Linux - Pakete laden

Verfasst: Sa Sep 01, 2018 9:42 am
von Hufeisen
Das Problem der Systemabhängigkeiten wird auch von den RStudioentwicklern angegangen: https://community.rstudio.com/t/install ... ncies/4811

Re: R unter Linux - Pakete laden

Verfasst: Sa Sep 01, 2018 10:03 am
von Hufeisen
Die Lösung? Ich denke, ich habe es jetzt.

Das Problem mit tmap: Die Liste der Abhängigkeiten für das tmap-Paket ist offensichtlich nicht vollständig. Das Paket setzt auf anderen Paketen auf, die wiederum auf sf aufsetzen. sf ist wohl unter starker Entwicklung, denn die Versionsnummer ist aktuell sf_0.6.3. Man muss die Sache also nun von hinten aufdröseln und sf installieren. Das hat bei mir (natürlich nicht geklappt).

Code: Alles auswählen

mp@Gert:~$ wget https://cran.r-project.org/src/contrib/sf_0.6-3.tar.gz
--2018-09-01 09:48:21--  https://cran.r-project.org/src/contrib/sf_0.6-3.tar.gz
Auflösen des Hostnamens cran.r-project.org (cran.r-project.org) … 137.208.57.37
Verbindungsaufbau zu cran.r-project.org (cran.r-project.org)|137.208.57.37|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: 7973054 (7,6M) [application/x-gzip]
Wird in »sf_0.6-3.tar.gz« gespeichert.

sf_0.6-3.tar.gz     100%[===================>]   7,60M   494KB/s    in 14s     

2018-09-01 09:48:35 (550 KB/s) - »sf_0.6-3.tar.gz« gespeichert [7973054/7973054]

mp@Gert:~$ sudo  R CMD INSTALL sf_0.6-3.tar.gz
* installing to library ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4’
ERROR: failed to lock directory ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4’ for modifying
Try removing ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4/00LOCK-sf’
Wie man am Ende sieht ist ein LOCK auf /home/mp/R/x86_64-pc-linux-gnu-library/3.4/00LOCK-sf . Wie, warum - keine Ahnung. Ich navigiere mit dem Fenstermanager (nemo) in das Verzeichnis und lösche den leeren Ordner /home/mp/R/x86_64-pc-linux-gnu-library/3.4/00LOCK-sf . Danach ließ sich sf installieren

Code: Alles auswählen

mp@Gert:~$ sudo  R CMD INSTALL sf_0.6-3.tar.gz
* installing to library ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4’
* installing *source* package ‘sf’ ...
** Paket ‘sf’ erfolgreich entpackt und MD5 Summen überprüft
configure: CC: gcc -std=gnu99
configure: CXX: g++
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.2.3
checking GDAL version >= 2.0.0... yes
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/share/gdal/2.2/pcs.csv readable... yes
checking GDAL: checking whether PROJ.4 is available for linking:... yes
checking GDAL: checking whether PROJ.4 is available fur running:... yes
configure: pkg-config proj exists, will use it
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
configure: PROJ: 4.9.3
checking for pj_init_plus in -lproj... yes
checking PROJ.4: epsg found and readable... yes
checking PROJ.4: conus found and readable... yes
checking for geos-config... /usr/bin/geos-config
checking geos-config usability... yes
configure: GEOS: 3.6.2
checking GEOS version >= 3.4.0... yes
checking geos_c.h usability... yes
checking geos_c.h presence... yes
checking for geos_c.h... yes
checking geos: linking with -L/usr/lib/x86_64-linux-gnu -lgeos_c... yes
configure: Package CPP flags:   -I/usr/include/gdal -I/usr/include
configure: Package LIBS: -lproj   -L/usr/lib -lgdal -L/usr/lib/x86_64-linux-gnu -lgeos_c
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c bbox.cpp -o bbox.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal.cpp -o gdal.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_geom.cpp -o gdal_geom.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_read.cpp -o gdal_read.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_utils.cpp -o gdal_utils.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_write.cpp -o gdal_write.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c geos.cpp -o geos.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c hex.cpp -o hex.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c proj.cpp -o proj.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c raster2sf.cpp -o raster2sf.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c sfg.cpp -o sfg.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c signed_area.cpp -o signed_area.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c stars.cpp -o stars.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/include -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c wkb.cpp -o wkb.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o sf.so RcppExports.o bbox.o gdal.o gdal_geom.o gdal_read.o gdal_utils.o gdal_write.o geos.o hex.o proj.o raster2sf.o sfg.o signed_area.o stars.o wkb.o -lproj -L/usr/lib -lgdal -L/usr/lib/x86_64-linux-gnu -lgeos_c -L/usr/lib/R/lib -lR
installing to /home/mp/R/x86_64-pc-linux-gnu-library/3.4/sf/libs
** R
** data
** demo
** inst
** preparing package for lazy loading
in method for ‘dbWriteTable’ with signature ‘"PostgreSQLConnection","character","sf"’: no definition for class “PostgreSQLConnection”
in method for ‘dbDataType’ with signature ‘"PostgreSQLConnection","sf"’: no definition for class “PostgreSQLConnection”
in method for ‘coerce’ with signature ‘"Spatial","sf"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"Spatial","sfc"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"sf","Spatial"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"sfc","Spatial"’: no definition for class “Spatial”
in method for ‘coerce’ with signature ‘"XY","Spatial"’: no definition for class “Spatial”
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (sf)
Danach ließ sich auch in R sf laden (library(sf)) und tmap installieren.

Code: Alles auswählen

install.packages("tmap")
Installiere Paket nach ‘/home/mp/R/x86_64-pc-linux-gnu-library/3.4’
(da ‘lib’ nicht spezifiziert)
installiere auch Abhängigkeiten ‘lwgeom’, ‘stars’, ‘tmaptools’, ‘mapview’

versuche URL 'https://cloud.r-project.org/src/contrib/lwgeom_0.1-4.tar.gz'
Content type 'application/x-gzip' length 432706 bytes (422 KB)
==================================================
downloaded 422 KB

versuche URL 'https://cloud.r-project.org/src/contrib/stars_0.1-1.tar.gz'
Content type 'application/x-gzip' length 4064586 bytes (3.9 MB)
==================================================
downloaded 3.9 MB

versuche URL 'https://cloud.r-project.org/src/contrib/tmaptools_2.0-1.tar.gz'
Content type 'application/x-gzip' length 84292 bytes (82 KB)
==================================================
downloaded 82 KB

versuche URL 'https://cloud.r-project.org/src/contrib/mapview_2.5.0.tar.gz'
Content type 'application/x-gzip' length 2012996 bytes (1.9 MB)
==================================================
downloaded 1.9 MB

versuche URL 'https://cloud.r-project.org/src/contrib/tmap_2.1-1.tar.gz'
Content type 'application/x-gzip' length 3055403 bytes (2.9 MB)
==================================================
downloaded 2.9 MB

* installing *source* package ‘lwgeom’ ...
** Paket ‘lwgeom’ erfolgreich entpackt und MD5 Summen überprüft
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: pkg-config proj exists, will use it
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
configure: PROJ: 4.9.3
checking for pj_init_plus in -lproj... yes
checking PROJ.4: epsg found and readable... yes
checking PROJ.4: conus found and readable... yes
checking for geos-config... /usr/bin/geos-config
checking geos-config usability... yes
configure: GEOS: 3.6.2
checking GEOS version >= 3.3.0... yes
checking geos_c.h usability... yes
checking geos_c.h presence... yes
checking for geos_c.h... yes
checking geos: linking with -L/usr/lib/x86_64-linux-gnu -lgeos_c... yes
checking for lwgeom_make_valid in -llwgeom... yes
checking for lwgeom_grid_in_place in -llwgeom... no
checking liblwgeom_internal.h usability... no
checking liblwgeom_internal.h presence... no
checking for liblwgeom_internal.h... no
configure: Package CPP flags:  -DPOSTGIS_GEOS_VERSION=35 -DHAVE_LIBGEOM -DNO_GRID_IN_PLACE
configure: Package LIBS:  -llwgeom
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -DPOSTGIS_GEOS_VERSION=35 -DHAVE_LIBGEOM -DNO_GRID_IN_PLACE -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/sf/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c geodetic.cpp -o geodetic.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -DPOSTGIS_GEOS_VERSION=35 -DHAVE_LIBGEOM -DNO_GRID_IN_PLACE -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/sf/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c lwgeom.cpp -o lwgeom.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -DPOSTGIS_GEOS_VERSION=35 -DHAVE_LIBGEOM -DNO_GRID_IN_PLACE -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/sf/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -DPOSTGIS_GEOS_VERSION=35 -DHAVE_LIBGEOM -DNO_GRID_IN_PLACE -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/sf/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c proj.cpp -o proj.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -DPOSTGIS_GEOS_VERSION=35 -DHAVE_LIBGEOM -DNO_GRID_IN_PLACE -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/sf/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c geos.cpp -o geos.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -DPOSTGIS_GEOS_VERSION=35 -DHAVE_LIBGEOM -DNO_GRID_IN_PLACE -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/sf/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c io.cpp -o io.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o lwgeom.so geodetic.o lwgeom.o RcppExports.o proj.o geos.o io.o -llwgeom -L/usr/lib/R/lib -lR
installing to /home/mp/R/x86_64-pc-linux-gnu-library/3.4/lwgeom/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (lwgeom)
* installing *source* package ‘stars’ ...
** Paket ‘stars’ erfolgreich entpackt und MD5 Summen überprüft
** R
** demo
** inst
** preparing package for lazy loading
in method for ‘coerce’ with signature ‘"stars","Raster"’: no definition for class “Raster”
in method for ‘coerce’ with signature ‘"stars","STFDF"’: no definition for class “STFDF”
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (stars)
* installing *source* package ‘tmaptools’ ...
** Paket ‘tmaptools’ erfolgreich entpackt und MD5 Summen überprüft
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (tmaptools)
* installing *source* package ‘mapview’ ...
** Paket ‘mapview’ erfolgreich entpackt und MD5 Summen überprüft
** libs
g++  -I/usr/share/R/include -DNDEBUG  -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
g++  -I/usr/share/R/include -DNDEBUG  -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c brewCppFun.cpp -o brewCppFun.o
g++  -I/usr/share/R/include -DNDEBUG  -I"/home/mp/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c mapviewCppFun.cpp -o mapviewCppFun.o
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o mapview.so RcppExports.o brewCppFun.o mapviewCppFun.o -L/usr/lib/R/lib -lR
installing to /home/mp/R/x86_64-pc-linux-gnu-library/3.4/mapview/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
in method for ‘mapView’ with signature ‘x="stars"’: no definition for class “stars”
in method for ‘viewRGB’ with signature ‘x="stars"’: no definition for class “stars”
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (mapview)
* installing *source* package ‘tmap’ ...
** Paket ‘tmap’ erfolgreich entpackt und MD5 Summen überprüft
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (tmap)
Ich werde jetzt in RStudio probieren, ob mein Skript regulär durchläuft. Mein Skript

Code: Alles auswählen

# Benötigte Pakete und Daten laden

  # Pakete für die Datenanalyse
  x <- c("reshape2", "ggplot2", "Hmisc")
  
  # Pakete für die Analyse räumlicher Objekte
  y <- c("sp", "rgdal", "tmap", "ncdf4", "rgeos", "ggrepel")
  
  # Pakete installieren - nur einmal erforderlich
  install.packages(x, dependencies = TRUE)
  install.packages(y, dependencies = TRUE)
  
  # Benötigte Pakete in R laden - bei jedem Start erforderlich
  lapply(x,  library,  character.only = TRUE)
  lapply(y,  library,  character.only = TRUE)
  rm(x, y)
Das läuft jetzt in RStudio ohne Fehler durch - soweit ich das sehen kann, denn die Anzahl der ausgeführten Schritte überschreiten die im Terminal behaltenen Zeilen.

@jogo - kannst du auf Ubuntu tmap installieren?

Re: R unter Linux - Pakete laden

Verfasst: Sa Sep 01, 2018 10:12 am
von jogo
Hallo Hufeisen,

die Installation von Debian-Paketen kann man nicht von RStudio aus lösen; das muss man an der KOnsole oder mit aptitude o.ä. lösen. Ich habe es üblicherweise an der Console gelöst. Das ständige sudo ... hat mich gestört, deshlb habe ich mir einmal mit sudo su die root-Shell besorgt und dann sowas wie

Code: Alles auswählen

apt-get install libdal-dev libgeos-dev ...
(darf auch mit zwei oder mehr apt-get geschehen)

Die obige Fehlermeldung beruht auf folgender Logik:
ggplot2 benötigt das Paket cairo,
cairo ist der Anschluss für die Systembibliothek libcairo;
als wird eine installierte Systembibliothek libcairo benötigt.

Gruß, Jörg

Re: R unter Linux - Pakete laden

Verfasst: Sa Sep 01, 2018 10:17 am
von Hufeisen
Gut, wie ist das deiner Erfahrung nach bzw. wie machst du es? Ich habe Paket nach Paket installiert und bin dann die Installationsmeldung nach Fehlern durchgegangen. R sagt einem ja mehr oder minder (manchmal muss man googeln), welche Pakete fehlen. Dann installiere ich die fehlenden Pakete im Terminal und probiere aus, ob es nun geht. Das ist wohl im wahrsten Sinne eine Frickellösung. Ein Befehl zum auflösen aller Abhängigkeitsprobleme gibt es wohl nicht?

Danke dir, für deine Ratschläge, die mich immerhin ermuntert haben, weiter zu frickeln. Ich werde versuchen meine Lösungsschritte etwas übersichtlicher aufzubereiten und im Thread des tmap Autors posten - da scheinen einige Probleme zu haben.

Re: R unter Linux - Pakete laden

Verfasst: Sa Sep 01, 2018 12:19 pm
von jogo
Hallo Hufeisen,

der Änderung des Titels entnehme ich, dass es jetzt läuft. sehr schön!
Hufeisen hat geschrieben: Sa Sep 01, 2018 10:17 am Gut, wie ist das deiner Erfahrung nach bzw. wie machst du es? Ich habe Paket nach Paket installiert und bin dann die Installationsmeldung nach Fehlern durchgegangen. R sagt einem ja mehr oder minder (manchmal muss man googeln), welche Pakete fehlen. Dann installiere ich die fehlenden Pakete im Terminal und probiere aus, ob es nun geht. Das ist wohl im wahrsten Sinne eine Frickellösung. Ein Befehl zum auflösen aller Abhängigkeitsprobleme gibt es wohl nicht?
Wie schon angedeutet mache ich die Installation von R-Paketen inzwischen mit RStudio, dort ist es der Menüpunkt Tools / Install Packages .... Das "mit RStudio" ist Augenwischerei, weil RStudio auch nichts anderes macht, als den Funktionsaufruf install.packages(..., dependencies=TRUE) generiert und R die eigentliche Arbeit erledigt.
Danke dir, für deine Ratschläge, die mich immerhin ermuntert haben, weiter zu frickeln. Ich werde versuchen meine Lösungsschritte etwas übersichtlicher aufzubereiten und im Thread des tmap Autors posten - da scheinen einige Probleme zu haben.
Zumindest kann man mal Fragen, worin die Probleme bestehen.

Gruß, Jörg
p.s.:
Ich freue mich, dass Du den Weg in dieses Forum gefunden hast. Bisher warst Du ja in dem Paralleluniversum. ;)