Loading...
 

1. Configuració d'R i associats a Ubuntu


1.1. Afegir repositori R 3.x a Ubuntu (rRutteR)

Si no tenim tot l'R 3.x instal·lat encara, afegir aquest repositori. Si ja tens una versió prèvia de R 3.x instal.lada, pots anar directament a l'apartat 1.2 i fer el sudo "apt-get update" i desde consola de R "update.packages(ask = F, checkBuilt = T)")

sudo su add-apt-repository -y ppa:marutter/rrutter # Needed for updated R 3.x add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable # Needed for tmap add-apt-repository -y ppa:opencpu/jq # Needed for tmap apt-get update -q exit


https://launchpad.net/~marutter/+archive/rrutter?field.series_filter=xenial

1.1.1. Ubuntu 16.04 i R 3.6

En Ubuntu 16.04, per poder disposar de R 3.5/3.6, cal afegir les claus gpg:

gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | sudo apt-key add -


I afegir aquestses linies a /etc/apt/sources.list

# update indices apt update -qq # install two helper packages we need apt install --no-install-recommends software-properties-common dirmngr # add the R 3.6 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' or 'xenial' as needed add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran35/"

1.1.2. Actualitzar la llista de paquets i l'R

Ara ja podem fer actualitzar la llista de paquets i actualitzar R:

sudo apt-get install r-base r-recommended


Users who need to compile R packages from source e.g. package maintainers, or anyone installing packages with install.packages() should also install the r-base-dev package:

sudo apt-get install r-base-dev


O via Synaptic Package Manager cercant la versió desitjada d'R-base..., marcant per instal·lar i clicant Apply

Si vols instal·lar els paquets complementaris de R per a tot l'ordinador (instala·lació de sistema), cal que donis permisos a la carpeta que s'empra per omissió /usr/lib/R/site-library, per exemple executant això en una consola:

sudo chmod 777 /usr/lib/R/site-library sudo chmod 777 /usr/lib/R/library


I si ja tens paquets instal·lats, i se't queixa R de que no pot actualitzar-los, cal que canviïs els permisos dels paquets ja instal·lats en aquestes dues carpetes, i la de la documentació en html ( /usr/share/R/doc/html/ ). Pots fer les dues coses (canviar permisos de la carpeta mare, els seus arxius i de les carpetes filles de forma recurrent amb:

sudo chmod 777 /usr/lib/R/site-library /usr/lib/R/site-library/* -R sudo chmod 777 /usr/lib/R/library /usr/lib/R/library/* -R sudo chmod 777 /usr/local/lib/R/site-library /usr/local/lib/R/site-library/* -R sudo chmod 777 /usr/share/R/doc/html/* -R


If using Ubuntu-mate, you seem to need to change perms on this folder also:

sudo chmod 777 /usr/local/lib/R/site-library /usr/local/lib/R/site-library/* -R


If using RRO, you have to change permissions here instead:

sudo chmod 777 /usr/lib64/RRO-8.0.3/R-3.1.3/lib/R/library /usr/lib64/RRO-8.0.3/R-3.1.3/lib/R/library/* -R sudo chmod 777 /usr/lib64/RRO-8.0.3/R-3.1.3/lib/R/doc/html /usr/lib64/RRO-8.0.3/R-3.1.3/lib/R/doc/html/* -R


Alternativament, R et demanarà de crear una carpeta personal on deixar els paquets que instal·laran per al teu usuari, tot i que més endavant, és molt possible que se't queixi igualment que algun paquet de sistema no el pot actualitzar perque no té prous permisos per fer-ho, etc. Així que potser millor donar permisos d'una vegada a que es puguin instal·lar o actualitzar els paquets d'R del sistema, amb les instruccions anteriors.

Per actualitzar els paquets d'R que no són a repositoris d'Ubuntu, cal obrir R i actualitzar paquets associats des de dins de la consola d'R:

update.packages(ask = F)


Si s'ha instal·lat algun paquet a la carpeta de paquets d'R de l'usuari, i es vol actualitzar el mateix paquet antic que hi ha a la carpeta del sistema, cal indicar-ho explicitament amb la instrucció:

update.packages(ask = F, lib="/usr/lib/R/site-library") update.packages(ask = F, lib="/usr/lib/R/library") update.packages(ask = F, lib="/usr/local/lib/R/site-library")

1.2. Install usual R packages

Usual R packages that are useful in many cases in the Bioinformatics world. You can install them in an R console in a terminal (Type "R" in the terminal to launch the R console), or through RStudio command line.

Run in an R console
install.packages(c("devtools", "plotly", "Nozzle.R1", "VennDiagram", "stringr", "xml2", "data.table", "doParallel", "xtable", "plyr", "dplyr", "reshape2", "rjson", "d3heatmap", "htmlwidgets", "googleVis", "doMC", "knitr", "checkpoint", "XLConnect", "sem", "rmarkdown", "relimp", "effects", "aplpack", "flexdashboards", "addinslist", "tidyverse", "magick", "webshot", "pacman", "officer", "flextable", "huxtable", "rio")) install.packages(c("Rcmdr", "RcmdrPlugin.survival", "RcmdrPlugin.HH", "RcmdrPlugin.EZR", "RcmdrPlugin.EBM", "RcmdrPlugin.sampling", "RcmdrPlugin.KMggplot", "RcmdrPlugin.ROC")) library(devtools);if(!require(rCharts)) install_github('rCharts', 'ramnathv') source("https://bioconductor.org/biocLite.R") biocLite(c("affylmGUI", "pd.mogene.1.0.st.v1", "oligo", "limma", "Biobase", "arrayQualityMetrics", "genefilter", "org.Mm.eg.db", "multtest", "annotate", "xtable", "GOstats", "gplots", "scatterplot3d", "VennDiagram", "edgeR", "pathview", "gage", "gageData","GenomicAlignments","TxDb.Hsapiens.UCSC.hg19.knownGene", "systemPipeR"))

1.3. Instal·lar BioConductor

1.3.1. Via bioCLite

Open the R console, and type inside:

source("http://bioconductor.org/biocLite.R") biocLite()

1.3.2. Instal·lar paquets bàsics de BioConductor (via Debian Med Ubuntu repository)

Alternativament, sembla que hi ha un repositori de paquets de biomedicina i bioinformàtica anomenat Debian Med, que té alguns paquets .deb de paquets de Bioconductor, per a algunes versions d'Ubuntu (no totes). El total de paquets és:

  • r-bioc-biobase
  • r-bioc-cummerbund
  • r-bioc-edger
  • r-bioc-limma


A part, hi ha altres versions de paquets útils (bwa, bowtie, etc). De totes formes, sembla que a 12.04 no hi ha paquets actualitzats de Debian-Med. En qualsevol cas, si es vol afegir, aquestes són les dues línies a afegir a /etc/apt/sources.list (canviar precise per la distro d'ubuntu)

sudo su add-apt-repository ppa:debian-med/ppa apt-get update apt-get install bamtools bambamc bwa exit

1.3.3. Instal·lar paquets NO bàsics de BioConductor (via Debian Med Ubuntu repository)

Mirar secció 5 d'aquesta mateixa pàgina

1.4. Instal·lar tots els paquets d'anotacions d'organisme

List available at:
http://bioconductor.org/packages/release/data/annotation/

Open the R console, and type inside:

Command on an R console
source("http://bioconductor.org/biocLite.R") biocLite(c("org.Ag.eg.db", "org.At.tair.db", "org.Bt.eg.db", "org.Ce.eg.db", "org.Cf.eg.db", "org.Dm.eg.db", "org.Dr.eg.db", "org.EcK12.eg.db", "org.EcSakai.eg.db", "org.Gg.eg.db", "org.Hs.eg.db", "org.Hs.ipi.db", "org.Mm.eg.db", "org.Mmu.eg.db", "org.Pf.plasmo.db", "org.Pt.eg.db", "org.Rn.eg.db", "org.Sc.sgd.db", "org.Sco.eg.db", "org.Ss.eg.db", "org.Xl.eg.db"))


This is useful, for instance, to use the goProfiles package.

Other usually needed annotation db packages for our pipeline include installing these oher (big) packages:

Command on an R console
source("http://bioconductor.org/biocLite.R") biocLite(c("pd.hta.2.0", "hta20stprobeset.db", "hta20sttranscriptcluster.db")) # For HTA microarrays pipeline biocLite(c("ade4", "affy", "annotate", "Biobase", "biomaRt", "Biostrings", "BSgenome", "bumphunter", "Cairo", "calibrate", "CNVassoc", "compareGroups", "data.table", "cqn", "DEoptimR", "DESeq", "DESeq2", "DMRcate", "DNAcopy", "doParallel", "doRNG", "edgeR", "epiR", "epitools", "FactoMineR", "ff", "flexclust", "flexmix", "foreach", "foreign", "formatR", "genetics", "GenomeGraphs", "GenomicFeatures", "GenomicRanges", "GEOquery", "glmmML", "GO.db", "GOstats", "gplots", "grid", "gridExtra", "GSEABase", "gtable", "gtool", "GWASTools", "hgu95av2.db", "hgu95av2cdf", "hgu133a.db", "iClusterPlus", "IlluminaHumanMethylation450k.db", "IlluminaHumanMethylation450kanno.ilmn12.hg19", "IlluminaHumanMethylation450kmanifest", "illuminaio", "IRanges", "limma", "lubridate", "maps", "matrixStats", "mclust", "methylumi", "omicade4", "org.Hs.eg.db", "org.Mm.eg.db", "org.Sc.sgd.db", "parallel", "Rsamtools", "rngtools", "RCurl", "Rcpp", "S4Vectors", "SNPassoc", "snpStats", "stringr", "survival", "sva", "tweeDEseq", "tweeDEseqCountData", "TxDb.Hsapiens.UCSC.hg18.knownGene", "TxDb.Scerevisiae.UCSC.sacCer3.sgdGene", "vegan", "wateRmelon", "wordcloud", "XML", "zoo", "RnBeads", "pathview", "Rsubread", "tweeDEseqCountData", "tweeDEseq", "cqn", "edgeR", "DESeq", "DESeq2", "DeconRNASeq", "GEOquery", "oligo", "rgcca", "srgcca")) # for RNA-seq pipeline

1.5. Actualitzar paquets de BioConductor (update.packages)

That is needed, for insatance, once you upgrade to a new version of R (from 2.13 to 2.14, for instance).

Open the R console, and type inside:

source("http://bioconductor.org/biocLite.R") update.packages(repos=biocinstallRepos(), ask=FALSE, checkBuilt=TRUE)


If you have some issues related to some packages (such as cairoDevice) not installing because they can't be tested (due to missing some X11 programs or others), try this other command, which prevents from attempting to test the installation of the remaining packages to install:

source("http://bioconductor.org/biocLite.R") update.packages(repos=biocinstallRepos(), ask=FALSE, checkBuilt=TRUE, INSTALL_opts="--no-test-load")



In recent Bioconductors (at least as of 2013), you can also use:

source("http://bioconductor.org/biocLite.R") biocLite("BiocUpgrade")



(Ricardo) Jo per aconseguir instal·lar el "affycoretools" ho he hagut de fer així:

source("http://bioconductor.org/biocLite.R") biocLite("affycoretools")


Alternatively, here you have some other tips (from Bioconductor email list):

Hi John,

On 11/8/2011 9:33 AM, John Coulthard wrote:
Hi

I'm trying to install Rsamtools and getting errors! I've tried...
install.packages("/home/ann/downloads/Rsamtools_1.6.0.tar.gz")
and
biocLite("Rsamtools")
(see below)


Why doesn't biocLite() install the current version?
I'm almost sure the dependencies are all up-to-date using install.packages().
So if it's not an out of date dependent what could the problem be?
If is it an out of date dependent how do I get R to tell me which one?

You appear to be going rogue here. You should not be using install.packages() at all, and should not be using an outdated version of biocLite().

You want

source("http://www.bioconductor.org/biocLite.R")

which will install the BiocInstaller package (and load it for you this time)

then in future, you should

library(BiocInstaller)
biocLite("Rsamtools")

which will

biocLite("Rsamtools")
BioC_mirror: 'http://www.bioconductor.org'
Using R version 2.14, BiocInstaller version 1.2.0.
Installing package(s) 'Rsamtools'

trying URL 'http://www.bioconductor.org/packages/2.9/bioc/src/contrib/Rsamtools_1.6.0.tar.gz'
Content type 'application/x-gzip' length 2088510 bytes (2.0 Mb)


Note the message I get compared to what you got.

Best,

Jim

1.6. Llibreries GNU/Linux necessàries per a instal·lar alguns paquets de R i Bioconductor


Copiar i enganxar aquesta comanda a un terminal:

Command on a console (Ubuntu 10.04 i 11.04)
sudo apt-get install r-cran-rgl r-cran-misc3d libx11-dev libxt-dev libcurl4-gnutls-dev libxml2-dev r-cran-xml libgraphviz4 libcairo2-dev r-cran-cairodevice freeglut3 freeglut3-dev libgtk2.0-dev

Command on a console (Ubuntu 11.10)
sudo apt-get install r-cran-rgl r-cran-misc3d libx11-dev libxt-dev libcurl4-gnutls-dev libxml2-dev r-cran-xml libgraphviz4 libcairo2-dev r-cran-cairodevice freeglut3 freeglut3-dev r-cran-rglpk libgtk2.0-dev

Command on a console (Ubuntu 12.04)
sudo apt-get install r-cran-rgl r-cran-misc3d libx11-dev libxt-dev libcurl4-gnutls-dev libxml2-dev r-cran-xml libgraphviz-dev libcairo2-dev r-cran-cairodevice freeglut3 freeglut3-dev r-cran-rglpk libgtk2.0-dev libnetcdf-dev netcdf-bin netcdf-doc

Command on a console (Ubuntu 14.04)
sudo apt-get install r-cran-rgl r-cran-misc3d libx11-dev libxt-dev libcurl4-gnutls-dev libxml2-dev r-cran-xml libgraphviz-dev libcairo2-dev r-cran-cairodevice freeglut3 freeglut3-dev r-cran-rglpk libgtk2.0-dev libglpk-dev libnetcdf-dev netcdf-bin netcdf-doc bwidget tk-table libv8-dev r-cran-rjava libmpfr-dev libc6-i386 libssl-dev r-cran-plyr r-cran-rmysql openjdk-7-jdk openjdk-7-jre-*

Command on a console (Ubuntu 16.04)
sudo apt-get install -y r-recommended r-cran-xml libgraphviz-dev libcairo2-dev r-cran-cairodevice freeglut3 freeglut3-dev r-cran-rglpk r-cran-rgl r-cran-misc3d libx11-dev libxt-dev libcurl4-gnutls-dev libxml2-dev r-cran-xml libgraphviz-dev libcairo2-dev bwidget tk-table libv8-dev r-cran-rjava libmpfr-dev libc6 libssl-dev texlive-latex-extra texlive-lang-spanish libx11-dev libxml2-dev libxml2:i386 libxt-dev r-cran-misc3d subversion git texmaker tk-dev unaccent xvfb libgdal1-dev libproj-dev r-cran-rmysql libmagick++-dev r-cran-rcolorbrewer r-cran-doparallel libssh2-1-dev libudunits2-dev libgdal-dev libgeos-dev libproj-dev libv8-dev libjq-dev libprotobuf-dev protobuf-compiler libssl-dev libcairo2-dev libglpk-dev

Paquet en R
Paquet en Fedora / Red Hat
Paquet en Debian / Ubuntu
Comentaris
rgl r-cran-rgl Llibreries de desenvolupament de software per X
r-cran-misc3d Miscelanea progs for rgl and 3d plots (on Ubuntu 11.04)
libX11-devel, libXt-devel libx11-dev, libxt-dev (OpenGl: freeglut3, freeglut3-dev)
Rglpk libglpk-dev r-cran-rglpk (on Ubuntu 14.04)
RCurl curl-devel libcurl3-dev
ó
libcurl4-gnutls-dev
Per processar algunes urls des de paquets d'R. En Actualitzar a R 2.14, vaig haver de re-instalar el paquet 'bitops' de bioconductor primer per tal que RCurl es pogués instal·lar bé (Xavi).
XML libxml2-dev libxml2-dev
r-cran-xml
Rgraphviz libgraphviz4
libgraphviz-dev
Té a veure amb la llibreria "graphviz" però no la he trobat a la Red Hat Network. Caldrà anar-la a cercar directament a altres repositoris. Jo no la tinc instal·lada (data 2008/06/05)
SNPassoc Instal·lat directament a R
MSnbase o ncdf libnetcdf-dev Instal·lar-lo via synaptic. Afegeix capçaleres netcdf.h
RNetCDF udunits-bin, libudunits2-dev Instal·lar-lo via synaptic. Afegir a l'anterior
GWASTools netcdf-bin
netcdf-doc
Instal·lar via synaptic, per a ncdf i GWASTools
cairo libcairo2-dev Instal·lar via gestor de paquets
r-cran-cairodevice Instal·lar via gestor de paquets
libxt-dev Instal·lar via gestor de paquets
libgtk2.0-dev Sembla que podria ser necessari per al cairoDevice en R 2.14+
Si tot i haver posat aquests paquets, es continua mostrant un prolema d'instal·lació, veure la "Nota sobre cairoDevice" de més avall.
affylmGUI bwidgets tk-table necessita tcl/tk, que necessita aquests paquets de sistema.
affycoretools libc6-i386 r-cran-rjava Sembla que necessita rjava també, i unes llibreries de 32 bits (que són a libc6-i386) per a que rJava funcioni.
RCmdr libv8-dev r-cran-rjava libmpfr-dev sembla que ho necessita el RCmdr, via els paquets d'R de dependènies "XLConnect" i "sem"
devtools libssl-dev seems to be needed by git2r, which is a dependency from devtools

 Nota sobre cairoDevice
Command on a console
> install.packages("cairoDevice") (...) installing to /usr/local/lib/R/site-library/cairoDevice/libs ** R ** demo ** preparing package for lazy loading ** help *** installing help indices ** building package indices ... ** testing if installed package can be loaded Error : .onLoad failed in loadNamespace() for 'cairoDevice', details: call: fun(libname, pkgname) error: GDK display not found - please make sure X11 is running Error: loading failed Execution halted ERROR: loading failed * removing \u2018/usr/local/lib/R/site-library/cairoDevice\u2019 * restoring previous \u2018/usr/local/lib/R/site-library/cairoDevice\u2019 The downloaded packages are in \u2018/tmp/RtmpHrgbZK/downloaded_packages\u2019 Warning message: In install.packages("cairoDevice") : installation of package \u2018cairoDevice\u2019 had non-zero exit status


You can solve this issue by passing a extra argument to install.packages in which you require R not to test the installation of cairo, since you are in a headless server with (eventually) some X11 libs (or *whatever*) missing.

Command on an R console to install cairoDevice sucessfully
install.packages("cairoDevice", INSTALL_opts="--no-test-load")


Instruccions sobre com trobar quin paquet de l'Ubuntu/Debian té les llibreries o paquets que li fan falta a l'R per poder instal·lar/compilar un paquet d'R:

gcc -I/usr/share/R/include -fpic -std=gnu99 -O3 -pipe -g -c Hmisc.c -o Hmisc.o In file included from /usr/include/bits/errno.h:25, from /usr/include/errno.h:36, from Hmisc.h:5, from Hmisc.c:1: /usr/include/linux/errno.h:4:23: error: asm/errno.h: No such file or directory


so the header file "asm/errno.h" cannot be found on your system, but is needed
to compile the Hmisc package sources. it's not a file from an R package, so
you can't fix it by installing other R packages. you need to find out which
ubuntu package provides it. run this on a console:

dpkg -S asm/errno.h


it will search for "asm/errno.h" in all available packages, and show you that
it's found in the package linux-libc-dev and linux header packages. once
you've installed what you need (e.g. "sudo aptitude install ",
i'd go for the linux-libc-dev package first), try the R installation again.

1.7. Java

Com arreglar problemes relacionats amb rJava, java, libjvm.so, rJava.so, ...

2024+: veure documentació a Posit:
https://solutions.posit.co/envs-pkgs/using-rjava/

1.7.1. Add Java 7-8-9 (JRE) from Sun/Oracle

If for some reason you need Java (jre) from Sun (currently Oracle), because the openjdk doesn't work for you (if you want to share your desktop with BigBlueButton, for instance, that doesn't seem to like the openjdk, or IPA requiring it), you can add the proprietary java through external repositories.

For JRE 7-8-9 from Oracle, you can add the webupd8 repos (ppa:webupd8team/java ; it was added in a previous step through the proxy, etc), and install the installer package:

Command on a console
# Install Java 8 sudo apt-get install oracle-java8-installer # Set the environments variables for Java 8 sudo apt-get install oracle-java8-set-default


Source:


If you need the earlier sun JRE 6 (keep in mind that you need a version like or higher than 1.6.0_23, because there were some known security holes with earlier versions):

Command on a console
sudo add-apt-repository ppa:flexiondotorg/java sudo apt-get update sudo apt-get install sun-java6


If you are behind a proxy, see the trick above to start a bash session as root and export the http_proxy and https_proxy variables.

Source http://www.ubuntuupdates.org/ppa/flexiondotorg_java_?dist=precise

1.7.2. Afegir Java per a R

Necessari per exemple per al paquet "xlsx", o "tabulizer".

Command on a console
sudo R CMD javareconf sudo apt-get install r-cran-rjava


1.7.3. Afegir rJava en projectes amb renv

Hi ha casos en que podem tenir rJava instal.lat bé a nivell de sistema (amb r-cran-rjava, per exemple) però no se'ns instal.la bé dins de projecte de R amb renv (malgrat indicar-li d'emprar la mateixa versió de rJava que tenim a nivell de sistema global fora del projecte amb renv).

En aquests casos, la documentació de posit ens ajuda a trobar la sol.lució:

#sudo apt-get install openjdk-8-jdk # Per a R 3.x sudo apt-get install openjdk-11-jdk # Per a R 4.x sudo su R CMD javareconf exit R renv::restore() # o renv::install("rJava@1.0-11") # per exemple o la versió que sigui i fer després un renv: :record() d'aquella versió q()


Derivat de:
https://solutions.posit.co/envs-pkgs/using-rjava/

1.7.4. Change the Java used by default

If you need to change the Java used by default, between OpenJDK & Sun/Oracle JRE, you must run:

sudo update-alternatives --config java


Then you can choose among the installed versions:

xavi@penguinbookpro:~$ sudo update-alternatives --config java [sudo] password for xavi: Hi ha 4 possibilitats per a l'alternativa java (que proveeix /usr/bin/java). Selecció Camí Prioritat Estat ------------------------------------------------------------ 0 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 mode automàtic 1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 mode manual 2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 mode manual * 3 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 mode manual 4 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 mode manual Premeu retorn per a mantenir l'opció per defecte[*], o introduïu un número de selecció: 0 update-alternatives: s'està emprant /usr/lib/jvm/java-7-oracle/jre/bin/java per a proveir /usr/bin/java (java) a «mode automàtic». xavi@penguinbookpro:~$

1.7.5. Fix the issue with rJava.so & libjvm.so

When installing rJava under Rstudio or other GUI programs (at least), you may see this type of error in some cases, at the R console:

...error: unable to load shared object '/home/xavi/R/x86_64-pc-linux-gnu-library/3.2/rJava/libs/rJava.so': libjvm.so


If you have oracle-java (7/8) installed. It'll be at this location /usr/lib/jvm and sudo access is required.

Solution:
Create the file /etc/ld.so.conf.d/java.conf

sudo nano /etc/ld.so.conf.d/java.conf


...with the following entries:

/usr/lib/jvm/java-8-oracle/jre/lib/amd64 /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server


(Replace java-8-oracle with java-7-oracle depending on your java version)

Then:

sudo ldconfig


Then, restart RStudio or whichever GUI program you use on top of R, and install rJava again.


1.8. Altres llibreries GNU/Linux necessàries per a instal·lar altres paquets d'R

1.8.1. Thematic maps - tmap

# install fundamental spatial libraries (needed for sf, sp, rgdal, rgeos) sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable sudo apt-get update sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev # install v8, needed for the R package V8 which reverse imports geojsonio and rmapshaper -> tmaptools -> tmap sudo apt-get install libv8-3.14-dev # install jq, needed for the R package jqr whith reverse imports: geojson -> geojsonio -> rmapshaper -> tmaptools -> tmap sudo add-apt-repository -y ppa:opencpu/jq sudo apt-get update -q sudo apt-get install -y libjq-dev # install libraries needed for the R package protolite, which reverse imports: geojson -> geojsonio -> rmapshaper -> tmaptools -> tmap sudo apt-get install -y libprotobuf-dev protobuf-compiler # other libraries sudo apt-get install libssl-dev sudo apt-get install libcairo2-dev

1.8.2. RMySQL

Per a instal·lar RMySQL, cal afegir aquests dos paquets:

A Ubuntu 10.04
sudo apt-get install libdbd-mysql libmysqlclient16-dev

A Ubuntu 12.04 i següents
sudo apt-get install libdbd-mysql libmysqlclient-dev r-cran-rmysql

1.8.3. Rgdal

Per a Bioconductor...
Per a instal·lar rgdal, per a bioconductor 2.11 (versió corresponent a R 2.15.2) pot ser necessari haver d'actualitzar el paquet gdal d'ubunu (Geospatial Data Abstraction Library) a una versió igual o superior a 1.7. Hi ha un repositori UbuntuGis stable que en té la versió 1.9.x per a Ubuntu Lucid 10.04:
https://launchpad.net/~ubuntugis/+archive/ppa

A part d'instal·lar la versió actualitzada llavors de gdal, cal eliminar (sembla) manualment el paquet libgdal1-1.6.0 i instal·lar el paquet libgdal1-1.8.0 i les dependències que correspongui.

Per a altres Mapes i GIS...
A Ubuntu 12.04...

sudo apt-get install libgdal1-dev libproj-dev


A Ubuntu 16.04

# Note: some system packages are needed for tmap to install properly in Ubuntu 16.04 systems # and for some of them you may need to add an extra repository (confirmed upto Ubuntu 16.04) sudo add-apt-repository -y ppa:opencpu/jq sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable sudo apt update sudo apt install libudunits2-0 libudunits2-dev libjq-dev libprotobuf-dev protobuf-compiler libgdal20


Package tmap (for Thematic Maps) in Ubuntu 16.04 seems to require the previous packages to be installed before attempting to install the tmap package in R.

1.9. Rstudio

Install rstudio (download version 0.99.878 or higher, which supports addins)

Add rstudio addins. Run this R code within the R terminal inside R Studio:

devtools::install_github("rstudio/addinexamples", type = "source") # ::


For more information, see:
http://rstudio.github.io/rstudioaddins/

1.10. Instal.lació de R conservant versions anteriors

1.10.1. Introducció

Aquest document pretén explicar com instal.lar en Linux noves versions de R, conservant les versions anteriors. Partirem de dues suposicions que no sempre han de ser certes, però ens faran simplificar el problema. La primera suposició (i la més important): el nostre sistema Linux té instal.lats tots els paquets necessaris per a que R i Bioconductor funcionin correctament (i compilin, si pot ser smile). Suposarem també, al menys de moment, que no hi ha cap versió anterior de R instal.lada, és a dir, que estem instal.lant R per primer cop (en cas de tenir-la, veure la secció Què fer si ja tenim un R instal.lat).

1.10.2. Consideracions prèvies

R en Linux acostuma a tenir una estructura de directoris bastant clara. Normalment, la instal.lació es fa en un directori de l'estil: <prefix>/<lib>/R, on <prefix> és un directori de l'estil “/usr” o “/usr/local”, i <lib> sol ser “lib64” (“lib” en el cas de Linux de 32-bits). A més, l'arxiu executable de R es sol trobar a <prefix>/bin. El problema ve quan volem instal.lar un altre paquest (.deb, .rpm, etc) amb una nova versió de R, perquè ens sobreescriurà els directoris existents de versions anteriors. Per evitar això, cal que anem un pas més enrera i compilem el codi font. És durant el procés d'instal.lació posterior a la compilació, on podrem especificar si volem un nom de directori diferent.

1.10.3. Compilació i instal.lació

Pasos a seguir:
  1. Hem de descarregar el “source code” de R-?.?.? de la pàgina web (R-?.?.?.tar.gz) a un directori diguem-li <downDir>.
  2. Hem d'obrir una consola, iniciar sessió com a root i anar al directori de descàrrega
    su -cd <downDir>)
  3. Hem de descomprimir i desempaquetar:
    tar xzf R-?.?.?.tar.gz
  4. El pas anterior ha creat un directori R-?.?.?, on hem d'entrar per a compilar i instal.lar.
    cd R-?.?.?
  5. El pas següent consisteix en compilar i crear els manuals:
    ./configure make make check make pdf

    El make check es fa per a comprovar que tot ha anat bé
    • Si pel que sigui, el ./configure falla amb quelcom com:
      configure: error: --with-readline=yes (default) and headers/libs are not available
      com en el cas d'instal·lar un R 2.5.x (necessari per al software Gene Pattern a ma amb opcions per defecte), prova de cridar el configure indicant-li on són els includes i les llibreries de X11:
      ./configure --x-includes=/usr/X11/include --x-libraries=/usr/X11/lib
  6. Ara cal fer la instal.lació (aquí és on indicarem el nou “rhome”)
    make install rhome=/usr/local/lib64/R-2.8.0
  7. Per últim, cal renombrar el fitxer executable R, que hauria d'estar a <prefix>/bin (en l'exemple anterior: /usr/local/bin)
    mv /usr/local/bin/R /usr/local/bin/R-2.8.0
Per fer que quan executem R en un terminal, s'ens obri l'R instal·lat des de repositoris (suposem que és la versió 2.13), i no pas l'R instal·lat des de SVN o per altres vies (per exemple, la 2.14), es poden executar aquest tipus d'instruccions en un terminal (adapta-ho al teu cas):
Command on a console
sudo mv /usr/local/bin/R /usr/local/bin/Rsvn sudo mv /usr/local/bin/Rscript /usr/local/bin/Rscriptsvn sudo ln -s /usr/bin/R /usr/local/bin/R sudo ln -s /usr/bin/Rscript /usr/local/bin/Rscript
Un cop fet això, en executar R en un terminal, s'obrià el 2.13. I en executar Rsvn, s'obrirà el 2.14.

1.10.4. Què fer si ja tenim un R instal.lat

En cas de tenir una versió de R instal.lada, el procés anterior sobreescriuria el fitxer binari <prefix>/bin/R existent. Per tant caldria, abans de fer la instal.lació del nou R, renombrar aquest fitxer. Per exemple: mv /usr/bin/R /usr/bin/R-2.7.0, i després procedir a la instal.lació de R-2.8.0.

1.10.5. Consideracions finals

Aquest document s'ha realitzat a partir de la documentació que es troba a la secció “Installing R under Unix-alikes”, del document <downDir>/R-?.?.?/doc/manual/R-admin.html. Possiblement hi ha maneres millors de fer tot això. Aquesta almenys funciona (al menys a RedHat EL 5.0).

1.11. Install R devel (sources) from subversion

Sources are also available via https://svn.R-project.org/R/, the R Subversion repository. If you have a Subversion client (see http://subversion.apache.org/), you can check out and update the current ‘r-devel’ from https://svn.r-project.org/R/trunk/ and the current ‘r-patched’ from ‘https://svn.r-project.org/R/branches/R-x-y-branch/’ (where x and y are the major and minor number of the current released version of R). E.g., use
svn checkout https://svn.r-project.org/R/trunk/ path
to check out ‘r-devel’ into directory path. The alpha, beta and RC versions of an upcoming x.y.0 release are available from ‘https://svn.r-project.org/R/branches/R-x-y-branch/’ in the four-week period prior to the release. Notes:
  • Note that ‘https:’ is required, and that the SSL certificate for the Subversion server of the R project should be recognized as from a trusted source.
  • Note that retrieving the sources by e.g. wget -r or svn export from that URL will not work: the Subversion information is needed to build R.
  • The Subversion repository does not contain the current sources for the recommended packages, which can be obtained by rsync or downloaded from CRAN. To use rsync to install the appropriate sources for the recommended packages, run from the top-level of the R sources:
    Command on a console
    ./tools/rsync-recommended
  • If you need to switch from trunk (devel) to any specific branch (such as from trunk to 2.14 during October 2011, in the 4-week period prior to the official release of branch 2.14.x), you can do so with:
    Command on a console
    export REPOS=https://svn.r-project.org/R svn switch $REPOS/branches/R-2-14-branch r-devel/R
  • If you want to fetch any specific branch from R directly through svn, you can do it by means of creating a new folder at the location you like (for instance, /home/youruser/r14-svn/), and run this command there:
Command on a console
svn checkout https://svn.r-project.org/R/branches/R-2-14-branch /home/youruser/r14-svn
If downloading manually from CRAN, do ensure that you have the correct versions of the recommended packages: if the number in the file VERSION is ‘x.y.z’ you need to download the contents of ‘http://CRAN.R-project.org/src/contrib/dir’, where dir is ‘x.y.z/Recommended’ for r-devel or x.y-patched/Recommended for r-patched, respectively, to directory src/library/Recommended in the sources you have unpacked. A suitable incantation from the top level of the R sources for R 2.14.0 using wget might be:
wget -r -l1 --no-parent -A\*.gz -nd -P src/library/Recommended http://CRAN.R-project.org/src/contrib/2.14.0/Recommended
After downloading manually you need to execute tools/link-recommended from the top level of the sources to make the requisite links in src/library/Recommended.
./tools/link-recommended
Then you can proceed to compile it, before being able to run it. Or optionally, you can also install it system-wide (not requried to run your new version of R).

1.11.1. Simple R compilation

As you are reading this file, you have unpacked the R sources and are presumably in the top directory. Issue the following commands:
./configure make
However, if you want to compile R with shared libraries, so that programs such as RStudio can use that R, you need to run the configure command with the extra option enable-R-shlib:
./configure --enable-R-shlib make
In case the making of the R program failed because of some old packages (such as "tools" or others compiled for earlier versions of R, etc), you can try cleaning the make environment first, and then call the make command again:
make clean make
(If your make is not called `make', set the environment variable MAKE to its name, and use that name throughout these instructions.) This will take a while, giving you time to read `R-admin.html'. Then check the built system worked correctly, by
make check
and make the manuals by (as many options as preferred from)
Command on a console
make dvi to create DVI versions make pdf to create PDF versions make info to create info files
However, please read the notes in `R-admin.html' about making the reference manual.

1.11.2. R Installation

You do not need to install R to run it: you can run R by the script `bin/R' which you can link or copy to any convenient place in your path. For a site-wide installation, use
Command on a console
make install make install-dvi make install-info make install-pdf
choosing to install the manuals that you made. This installs to the default location (typically `/usr/local') for your platform: see the Installation and Administration Manual for other options.
For more information, or more detailed instructions, see: http://developer.r-project.org/SVNtips.html

1.12. Check devel Bioconductor packages corresponding to the R devel version

You can check them here: http://bioconductor.org/checkResults/devel/bioc-LATEST/

1.13. Eclipse Visual Debugger for R (StatEt)

To install Eclipse & Statet (for the visual debugger), you need to compiple R for yourself after applying a small patch to an R source file, and your need to follow these extra (non fully-intuitive) steps:
  1. Download your copy of R source (from subversion or other means), so that you can compile it later.
  2. Apply the patches from http://www.walware.de/it/downloads/statet.mframe for your version of R
  3. build and install R
  4. Add rj package in your R installation. http://www.walware.de/it/downloads/rj.html
    Add rj package in your R installation
    install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-1.1")
  5. Install StatEt by hand (it seems that Eclipse doesn't use theproxy info we provided):
  6. Follow the tutorial from Eclipse once the Statet is installed for the configuration, etc.
  7. Launch the R Console no longer from the Run configurations menu (or favorites), but from the Debug configurations menu (or favorites) in order to have the debugger functionality activated
  8. set breakpoints in your functions
  9. use either Ctrl+R, Ctrl+F (submit function) or Ctrl+R, Ctrl+S (source the file) in order to install your breakpoints (the breakpoint icon will have a check in that case)
  10. run the code and the Debug perspective will be opened with a Variables View, Breakpoints View, a nice overview of the stack etc. You can step through your code using F6. To emulate a step-in, put the cursor on the function want to step into and press Ctrl+F5.
See also this tutorial on the Eclipse Debugger (for Java), which might serve as an introduction resoruce for beginners in Eclipse and/or Debugging. http://eclipsetutorial.sourceforge.net/debugger.html From email lists (they are citing our video from User!2011 !!):

[StatET-user] StatET support for visual/advanced R debugging
Tobias Verbeke tobias.verbeke at openanalytics.eu
Thu Aug 25 08:04:54 CEST 2011

Hi Brian,

On 08/24/2011 03:34 PM, Brian G. Peterson wrote:
On Wed, 2011-08-24 at 16:09 +0300, Jonathan Rosenblatt wrote:
It was presented in UseR2011
Try StatET2.0 from http://www.walware.de/it/statet/installation.mframe

I'm thrilled to hear that, but it appears that the update site:

http://download.walware.de/user2011

is blocked. Perhaps it was only available during UseR!2011 ?

I just tested with a vanilla Indigo (Eclipse for Java developers)
and it installs without hiccups.

You get a 404 when browsing to the URL, but if you enter
the address as an update site (under Help Install New Software
Add) things work out perfectly fine.

Is the StatET presentation from useR available?

There is a small video fragment here:

http://vimeo.com/27901400

The short installation instructions are:

1) apply the patches from
http://www.walware.de/it/downloads/statet.mframe
for your version of R

2) build and install R

3) install the latest and greatest StatET from the
above URL

4) launch the R Console no longer from the Run configurations
menu (or favorites), but from the Debug configurations menu
(or favorites) in order to have the debugger functionality
activated

5) set breakpoints in your functions

6) use either Ctrl+R, Ctrl+F (submit function) or Ctrl+R, Ctrl+S (source
the file) in order to install your breakpoints (the breakpoint
icon will have a check in that case)

7) run the code and the Debug perspective will be opened with a
Variables View, Breakpoints View, a nice overview of the stack etc.
You can step through your code using F6. To emulate a step-in, put
the cursor on the function want to step into and press Ctrl+F5.

8) Have fun as never before.

There is some more documentation in the StatET User Guide you
can find under Help Help Contents StatET User Guide R Visual Debugger.

We made some installers for Windows and Mac (with patched R
included), but they are not ready for production yet (working
around some Windows limitations for the moment) — currently
they serve primarily to play with the debugger functionality.
I can send the link privately to interested people.

Don't hesitate if you would have further questions.

Best,
Tobias

1.14. Darrera versió estable de RKward

sudo add-apt-repository ppa:rkward-devel/rkward-stable

1.15. Solventar temporalment el problema del proxy amb Sys.setenv

Si ho necessitem per alguna raó, podem configurar una sessió d'R per a emprar el proxy, amb aquesta comanda dins de la consola d'R (via pàgina wiki i pluginR, via RKward, via RStudio, etc):
Command on an R console
Sys.setenv(http_proxy="http://your.proxy.domain:yourport")

1.16. Afegir els menus contextuals de Bazaar a RKward i altres KDE apps

Veure "QBazaar service menu": http://kde-look.org/content/show.php/QBazaar+service+menu?content=142321

Service menu for kde apps (such as Dolphin 1.6.x, rkward 0.5.7., ...) so that you can launch a few actions for QBazaar (program of a distributed version control system)

Merged information from two previous sources (1 & 2, see below) and adapted for the case where there was no folder \"ServiceMenu\" created for the user (under gnome desktop).

Sources:
(1) http://blog.saturnlaboratories.co.za/programs/qbazaar-desktop
(2) http://kde-apps.org/content/show.php/Bazaar-Servicemenu?content=115751

Thanks Thomas Friedrichsmeier for feedback.

Download this file and install it with the provided script inside the downloaded compressed file: http://kde-look.org/content/download.php?content=142321&id=1&tan=1082686

2. renv

Veure: renv

3. Using Multiple Versions of R in Linux

If using Posit Workbench (former RStudio Server Pro), see: https://docs.posit.co/ide/server-pro/r/using_multiple_versions_of_r.html If using Rstudio Server open source, see: https://docs.posit.co/resources/install-r/#optional-install-multiple-versions-of-r

4. Us segur de contrasenyes via .Renviron

Resum del Procés:
  • Es defineix una variable de sistema que conté la contrasenya d'interés. I des d'R, al nostre codi, no posem la contrasenya a l'arxiu .R o .Rmd, sinó que posem una referència a la variable de sistema que té nostra que ens interessa.Studio-Workbench---Pla-de-Treball?latest=1
  • Les parelles variable=contrasenya es desen en un arxiu de text pla anomenat .Renviron en la nostre carpeta d'usuari /home/usuarilinux/.Renviron
    Si no veus aquest arxiu amb el navegador d'arxius (habitualment amb el programa Dolphin per omissió del Kubuntu), prova a activar l'opció de mostrar els arxius ocults.
    • Cal assegurar-se que aquest arxiu té permisos de lectura només per a l'usuari que l'ha creat. Especialment important en màquines en les que hi entrin més usuaris, per evitar que quedin exposades contrasenyes innecessàriament. En GNU/Linux (com Kubuntu) ho podem fer amb la instrucció:
      chmod 600 /home/usuarilinux/.Renviron
  • Exemples de sintaxi dins d'aquest arxiu .Renviron
    variable1=LaMevaContrasenya1 r_oracle_ajbcn_padroibc_pwd=fooBar r_oracle_ajbcn_barcino_pwd=blabla1234567
  • Un cop afegides noves variables de l'arxiu .Renviron, cal reiniciar la sessió de R/RStudio, per que les variables de sistema les llegeix R en iniciar la seva sessió de treball.
  • Des de l'script d'R emprem aquesta informació amb la crida de sistema a emprar el contingut d'aquesta variable, amb la funció d'R: Sys.getenv().
    Exemple de codi:
    df1 <- fetch.oracle(entorn = oracle.env, usuari_esquema = oracle.user.1, contrasenya_esquema = Sys.getenv("r_oracle_ajbcn_padroibc_pwd"), query = oracle.query.1) # Sys.getenv("r_oracle_ajbcn_padroibc_pwd"):

4.1. Edició Renviron a través de paquet usethis

usethis :package: has a useful helper function to modify .Renviron :
  • usethis::edit_r_environ() will open your user .Renviron which is in your home
  • usethis::edit_r_environ("project") will open the one in your project

5. Errades i Solucions

5.1. maximal number of DLLs reached

Si veus aquest problema per la consola d'R i s'atura el procés d'R que estàs executant, pots provar a afegir a l'-+.Renviron+- de l'usuari (per tal que s'incrementi el valor de Dll que es poden obrir a l'hora de 256, que sembla que dona problemes en alguns casos, a 1000, per exemple, si ja n'hi ha prou per esquivar el problema)
nano ~/.Renviron
Afegir al final:
R_MAX_NUM_DLLS=1000
I fer Ctrl + X per sortir desant canvis.

5.2. Problemes rutes en R a Windows AjBCN

CMD.EXE se inici¢ con esta ruta como el directorio actual. No se permiten rutas UNC. Regresando de manera predeterminada al directorio Windows.
Sembla que en alguns casos la instal·lació de paquets d'R sobre windows dona missatges d'avís (o error? - confirmar). Exemple d'un intent d'instal·lació/ actualitzaciód e paquets d'R al perfil d'usuari del Xavier (F692118) en Windows 10 a l'ordinador de la feina:
... *** copying figures ** building package indices ** installing vignettesStudio-Workbench---Pla-de-Treball?latest=1 Warning in file(con, "w") : cannot open file '\\Nas_USR2/USR2/8/USR/F692118/R/win-library/3.4/broom/doc/index.html': No such file or directory Error in file(con, "w") : cannot open the connection ERROR: installing vignettes failed * removing '\\Nas_USR2/USR2/8/USR/F692118/R/win-library/3.4/broom' * restoring previous '\\Nas_USR2/USR2/8/USR/F692118/R/win-library/3.4/broom' In R CMD INSTALL Warning in install.packages : running command '"C:/PROGRA~1/R/R-34~1.4/bin/x64/R" CMD INSTALL -l "\\Nas_USR2\USR2\8\USR\F692118\R\win-library\3.4" C:\Users\f692118\AppData\Local\Temp\Rtmp2RRbvm/downloaded_packages/broom_0.5.2.tar.gz' had status 1 Warning in install.packages : installation of package ‘broom’ had non-zero exit status '\\nas_usr2\USR2\8\USR\F692118\Codi\curs-r-introduccio' CMD.EXE se inici¢ con esta ruta como el directorio actual. No se permiten rutas UNC. Regresando de manera predeterminada al directorio Windows. * installing *source* package 'ggplot2' ... ** package 'ggplot2' successfully unpacked and MD5 sums checked ** R ** data *** moving datasets to lazyload DB ** inst ** preparing package for lazy loading ** help ...
La solució es reinstal·lar l’aplicació, com administrador, i triar un directori al disc C. Un altre problema, detectat en voler cosir (knit) un Rmd del curs d'R:
processing file: extra.tips.guia.vis.gencat.Rmd |...................... | 33% inline R code fragments |........................................... | 67% label: setup (with options) List of 1 $ include: logi FALSE |.................................................................| 100% ordinary text without R code output file: extra.tips.guia.vis.gencat.knit.md "C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS extra.tips.guia.vis.gencat.utf8.md --to slidy --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output extra.tips.guia.vis.gencat.html --email-obfuscation none --self-contained --template "\\Nas_USR2\USR2\8\USR\F692118\R\win-library\3.5\rmarkdown\rmd\slidy\default.html" --variable "footer=Copyleft 2019, OMD-AjBCN. http://omd-gid.imi.bcn/CursR" --include-in-header apunts_capcalera.html --include-after-body apunts_peu.html --css styles.css --include-in-header "C:\Users\f692118\AppData\Local\Temp\Rtmp6P2648\rmarkdown-strb702f5c6553.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --highlight-style pygments Could not fetch http://?/UNC/Nas_USR2/USR2/8/USR/F692118/R/win-library/3.5/rmarkdown/rmd/slidy/default.html HttpExceptionRequest Request { host = "" port = 80 secure = False requestHeaders = [] path = "/" queryString = "?/UNC/Nas_USR2/USR2/8/USR/F692118/R/win-library/3.5/rmarkdown/rmd/slidy/default.html" method = "GET" proxy = Nothing rawBody = False redirectCount = 10 responseTimeout = ResponseTimeoutDefault requestVersion = HTTP/1.1 } (InvalidDestinationHost "") Error: pandoc document conversion failed with error 61 Execution halted

6. Modern Geospatial Data analysis

Zev Ross (@zevross) ha tuitat a les 2:29 p. m. on dt., febr. 04, 2020:
I had the privilege of teaching a two-day workshop, Modern Geospatial Data Analysis with R, at the @rstudio conference with an amazing group of TAs and participants. I've made the slides available here: https://t.co/rSzPTt6VBk, #rstats, #rspatial, #gischat https://t.co/3v7UVd0UT5
(https://twitter.com/zevross/status/1224686455274070017?s=09)

URL: http://files.zevross.com/workshops/spatial/slides/html/0-deck-list.html

7. Conversions coordenades geo

EPSG de projeccions habituals de coordenades en el cas AjBCN:
  • projecció coordenades ed50 (UTM) fus31, epsg: 23031
  • projecció coordenades etrs89 (UTM) fus31, epsg: 25831
  • projecció coordenades wgs84 (lon lat), epsg: 4326
Exemples de sintaxis de conversió de coordenades geogràfiques (i altres tasques habituals) que sovint em costa trobar quan ho necessito mesos després de fer-ho servir alguna vegada
# Reemplacem ara lon i lat (wgs87) amb els valors convertits des de x, y etrs89 #fem geometria a partir de x, y del dataframe i2 # convertim geometria de coordenades etrs89 a coordenades wgs87 # reemplacem valors columnes lon lat amb els nous valors provinents de nova geometria reprojectada a wgs87 d3 <- i2 %>% select(-lon, -lat) %>% mutate(x.etrs89=x, y.etrs89=y) #d3$lon <- as.double(gsub(",", ".", as.character(d3$lon)), options(digits=16)) #d3$lat <- as.double(gsub(",", ".", as.character(d3$lat)), options(digits=16)) Studio-Workbench---Pla-de-Treball?latest=1 #d3$x <- as.double(gsub(",", ".", as.character(d3$x)), options(digits=3)) #d3$y <- as.double(gsub(",", ".", as.character(d3$y)), options(digits=3)) d3_sf <- st_as_sf(d3, coords = c('x', 'y'), crs = st_crs(barris)) d3_sf.wgs84 <- st_transform(d3_sf, crs=4326) #st_geometry(d3_sf) d3_sf.df.lonlat <- cbind(data.frame(d3_sf), st_coordinates(d3_sf.wgs84)) d3.lonlat <- d3_sf.df.lonlat %>% data.frame() %>% rename(lon=X, lat=Y, x=x.etrs89, y=y.etrs89) %>% select(-geometry) d3.lonlat$lon <- as.double(gsub(",", ".", as.character(d3.lonlat$lon)), options(digits=16)) d3.lonlat$lat <- as.double(gsub(",", ".", as.character(d3.lonlat$lat)), options(digits=16)) # Deso una còpia a disc, per a reaprofitar la feina en altres llocs (apps shiny, etc) st_write(d3_sf.df.lonlat, "d3.xy.csv", layer_options = "GEOMETRY=AS_XY") st_write(d3_sf.df.lonlat, "d3.wkt.csv", layer_options = "GEOMETRY=AS_WKT")

8. Instal.lar paquets darrera proxy firewall GlobalProtect a Windows - metode wininet

Lo de definir el proxy via sys.setenv no m'ha funcionat . Ni afegint curl via renv
equip() #
Sembla que una forma que si qu efa, és definir el mètode antic "wininet" per descarregar els arxius a instal·lar via
install.packages("foo", method="wininet")

Noms alias d'aquesta pàgina: R | R i associats | ess | statet | eclipse | Configuració d'R i associats | ConfiguracióR | ConfiguracioR | RConf | RConfiguration | Config R | R Config
Image Seed: noun \ˈsēd\ : the beginning of something which continues to develop or grow

Knowledge seeds

Switch Language