Unable to install `sf `on R version 4.1.2 - r

I upgrade to R version 4.1.2 but now I cannot install sf package because the package it not available for this version of R supposedly
I downloaded the file from 'https://cran.rstudio.com/bin/macosx/contrib/4.1/sf_1.0-4.tgz' and try to install from a local file because when I tried to use install.packages("sf") the download timeout
Please could somebody provide some ideas of what I am doing wrong?

Try
install.packages(file.choose(), repos = NULL)
This will both (1) tell R that you are installing from a local file; (2) allow you to choose the file interactively, making sure that you're not making a mistake with the name or the extension.
I don't think you'll need type = "source" in this case, but it wouldn't hurt.
If you do need to install from source, be prepared for the fact that sf needs several external, system libraries:
SystemRequirements: C++11, GDAL (>= 2.0.1), GEOS (>= 3.4.0), PROJ (>=
4.8.0), sqlite3
It might be worth trying the installation from the repository again (possibly after setting options(timeout = 600) as suggested by #jared_mamrot) — it might be a transient problem — since that will skip any headaches with installing system libraries.

Related

package 'lubridate' installation error: compilation failed for package 'lubridate' [duplicate]

A friend sent me along this great tutorial on webscraping The New York Times with R. I would really love to try it. However, the first step is to install a package called [RJSONIO][2] from source.
I know R reasonably well, but I have no idea how to install a package from source.
I'm running macOS (OS X).
If you have the file locally, then use install.packages() and set the repos=NULL:
install.packages(path_to_file, repos = NULL, type="source")
Where path_to_file would represent the full path and file name:
On Windows it will look something like this: "C:\\RJSONIO_0.2-3.tar.gz".
On UNIX it will look like this: "/home/blah/RJSONIO_0.2-3.tar.gz".
Download the source package, open Terminal.app, navigate to the directory where you currently have the file, and then execute:
R CMD INSTALL RJSONIO_0.2-3.tar.gz
Do note that this will only succeed when either: a) the package does not need compilation or b) the needed system tools for compilation are present. See: R for Mac OS X
You can install directly from the repository (note the type="source"):
install.packages("RJSONIO", repos = "http://www.omegahat.org/R", type="source")
A supplementarily handy (but trivial) tip for installing older version of packages from source.
First, if you call "install.packages", it always installs the latest package from repo. If you want to install the older version of packages, say for compatibility, you can call install.packages("url_to_source", repo=NULL, type="source"). For example:
install.packages("http://cran.r-project.org/src/contrib/Archive/RNetLogo/RNetLogo_0.9-6.tar.gz", repo=NULL, type="source")
Without manually downloading packages to the local disk and switching to the command line or installing from local disk, I found it is very convenient and simplify the call (one-step).
Plus: you can use this trick with devtools library's dev_mode, in order to manage different versions of packages:
Reference: doc devtools
From CRAN, you can install directly from a GitHub repository address. So if you want the package at https://github.com/twitter/AnomalyDetection, using
library(devtools)
install_github("twitter/AnomalyDetection")
does the trick.
In addition, you can build the binary package using the --binary option.
R CMD build --binary RJSONIO_0.2-3.tar.gz

Having Issues installing tabulizer package in R

I had a script working with tabulizer, but had to clean my hard drive and reinstall R, and now I cant seem to even download and access the tabulizer library. I am now using R version 4.1.2 64 bit, and am thinking maybe I need to use an earlier version of R??? Here is the error message I get when I try and install tabulizer.
install.packages("tabulizer")
Installing package into ‘C:/Users/cdonner/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘tabulizer’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
I have tried to go to go to Cran (https://cran.r-project.org/src/contrib/Archive/tabulizer/) and download and unzip the libraries to my directory, but then I get an errors again. Any ideas? Thanks.
Enter this into the command window!
remotes::install_github(c("ropensci/tabulizerjars", "ropensci/tabulizer"), INSTALL_opts = "--no-multiarch")
It is not on CRAN.
You have to install using
ghit::install_github("ropensci/tabulizer")
or
devtools::install_github("ropensci/tabulizer")
github
I have just come to dealing with the same problem, but I got to solve it through the following steps:
the tabulizer package requires a Java environment. You need to download Java 64-bit or Java 32-bit through.
Make sure before that your windows/ mac is 32 bit or 64 bit by using the function sessionInfo().
Install the rJava package in R.
Create the Java environment through the command: Sys.setenv(JAVA_HOME="C:/Program Files/Java/jdk-18/")
Attention: the path of the file in step 3 is for java 64. the path for java 32 would be Sys.setenv(JAVA_HOME="C:/Program Files (x86)/Java/jdk-18/").
The other thing is that jdk-18 changes depending on everylaptop, in my case it is jdk-18, in your case it could jdk-17 for example.
Finally activate the library: library(rJava)
Voila. rJava and tabulizer work smoothly and nicely.
Got the same problem. (A lot) Packages were missing
I had to update R
Install java for R
Install Rtools42 from CRan
Install remotes
before running the command of #Dunbar111
remotes::install_github(c("ropensci/tabulizerjars", "ropensci/tabulizer"), INSTALL_opts = "--no-multiarch")

Install sf for r using gdal from postgresapp

I am on MacOSX 11.4 Big Sur.
I have just installed on my computer https://postgresapp.com, which bundles PostgreSQL together with the needed libraries for PostGIS (proj, geos, and gdal).
I am able to use command line functions like ogr2ogr, gdalinfo etc. from my terminal, indicating that gdal is successfully installed.
I now want to install the "sf" package for R version 4.1.0. I am able to successfully install "sf", but the PostgreSQL driver is missing when I use the native installation
install.packages("sf")
According to the sf documentation and things I have read elsewhere on stack, this is a known issue for MacOSx, and the recommended workaround for this problem is to separately install gdal using homebrew or the kyngchaos binaries. However, I would like to use the gdal installation used by the postgresapp binary mentioned earlier so that there is only one installation on my computer..
According to the postgresapp installation documentation (https://postgresapp.com/documentation/install.html), the relevant paths are:
Binaries: /Applications/Postgres.app/Contents/Versions/latest/bin
Headers: /Applications/Postgres.app/Contents/Versions/latest/include
Libraries: /Applications/Postgres.app/Contents/Versions/latest/lib
Therefore, when combined with the "sf" documentation my assumption is that the following should work.
install.packages("sf", configure.args = "--with-gdal-lib=/Applications/Postgres.app/Contents/Versions/latest/lib/"
Although I receive no errors or warnings, this does not fix the problem for me as sf::st_drivers() still does not list the PostgreSQL driver as an option. Can someone please help me figure out what additional configuration arguments, if any, are needed to get sf to recognise the Postgres driver?

While I install my R package (for testing) it also re-installs all the dependencies (first time) that are already present on the system

I have a code to track objects in the images. This code uses few function from the package clue. So clue is already installed in my system. Now I have created a package using the same code.
My description file has following lines.
Depends: R (>= 3.4.3),
clue
Because clue is already installed, I thought it will not get installed again when I use install("mypackage"). But to my surprise it re-installed the package. I have tried this with other installed packages, too. When I give it as "depends" or "import", it re-installs the packages. I do not want to re-install the packages if they are already on my system. Is there a way to tell R package installer to avoid re-installing packages that exist on the user's system? Some of these packages are quite large and take a lot of time to install. In addition, I have installed some packages with binary source/dependency that required me to give path for several libraries.
You can just use
install.packages(..., dependencies = FALSE)
or if you use devtools::install:
install(..., dependencies = FALSE)

unable to access index for repository in R

I am on Windows 7 and I am using R Studio 0.99.902 with R3.3.1. When I am trying to install a package I get the Warnings:
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib:
cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
It is the first time I see it and I cannot solve it. Can anyone help me ?
This issue is likely caused by the package being too old or too new for your R version. For example, if a package is released during R-3.4.1, it will not be available for R-3.3.1. Packages which are removed from CRAN before your R version are also not available. The package DESCRIPTION file shows if there is a hard restriction on which R versions the package will run.
Search for the package's CRAN page and see its status. You may still be able to install the package by downloading the package source (the tar.gz file) and in RStudio selecting Install from: Package Archive File in the Tools/Install Packages... menu (or using install.packages with repos = NULL). Beware that the package is not available from CRAN for a reason; you may need to make some changes to the package for it to work correctly.
Running options(download.file.method="libcurl") then installing packages did the trick for me. You may find an answer here.
Please note that compiling from source for Windows requires the appropriate version of Rtools that is compatible with the R version you are working with. This list is available at the Rtools site:
https://cran.r-project.org/src/contrib/Archive/
If compilation from source is complicated, it is also possible to find the Windows-compiled binaries (.zip files) for older versions of R at:
https://cran-archive.r-project.org/bin/windows/contrib
This link is referenced by the ReadMe file available at the "regular" repository for Windows binaries for different versions of R, namely at:
https://cran.r-project.org/bin/windows/contrib
Once the zip file is downloaded, you can run the following R code line to install the package:
# Use repos=NULL so that the first argument is a path to the local zip file
# containing the binary package to install
# (as opposed to just the name of the package to install from the web)
install.packages("<local-path-to-downloaded-zip-file>", repos=NULL)

Resources