install.packages("ebvcube")2 Installing software and the ebvcube R package
By the end you will be able to:
- confirm that your R installation meets the requirements for
ebvcube; - install the
ebvcubepackage and its dependencies; - verify your setup by loading the package and opening an example dataset.
This unit prepares your machine for the rest of the tutorial. You install ebvcube and its dependencies, then test the installation by opening an example dataset. Once that works, you are ready to prepare your own data in Unit 3.
2.1 What you need first
Before installing ebvcube, make sure you have:
R ≥ 4.2.0 required
The minimum version ebvcube supports. Check yours with R.version.string, and if it is older, update R first, or CRAN will refuse to install the package.
RStudio recommended
A free, widely used editor for R. It is not required, but it makes it easier to run, save, and revisit the code in this tutorial. Download it here.
On Windows and macOS, you will usually not need to install HDF5 or GDAL yourself. Bioconductor supplies HDF5 through rhdf5, while CRAN binary builds of terra normally include the spatial libraries they need. Linux installations can require additional system libraries; Unit 7 covers the common fixes.
2.2 Installing ebvcube from CRAN
For most users, the released version on CRAN is all you need:
CRAN resolves all of the CRAN dependencies automatically. Three dependencies, however, live on Bioconductor rather than CRAN, so on a fresh machine you will usually need the one-time step in the next section as well.
Most people should use CRAN. If you need a newer feature, you can install the development version with devtools::install_github("EBVcube/ebvcube", ref = "dev"), or get the binary builds from the b-cubed r-universe. These are covered in the package’s installation guide.
2.3 Adding the Bioconductor dependencies
Three of ebvcube’s dependencies come from Bioconductor rather than CRAN, because reading EBVCube files means reading HDF5 under the hood:
rhdf5
Low-level HDF5 read/write, since netCDF-4 is HDF5 underneath.
DelayedArray
Lazy, on-disk arrays so large cubes do not exhaust your RAM.
HDF5Array
Connects DelayedArray to HDF5 files.
If installing ebvcube reports that one of these is missing, install them with BiocManager:
install.packages("BiocManager")
BiocManager::install(c("rhdf5", "DelayedArray", "HDF5Array"))You only need to do this once per R installation.
BiocManager automatically selects the Bioconductor release that matches your version of R. Leave the version unspecified unless a package maintainer or a project requirement tells you otherwise.
2.4 Verifying your installation
First, load the package and confirm the version:
library(ebvcube)
packageVersion("ebvcube")Then open the small example dataset that ships with the package. Because it is bundled, this needs no download and works offline, making it a reliable installation check:
file <- system.file("extdata", "martins_comcom_subset.nc", package = "ebvcube")
prop <- ebv_properties(file, verbose = FALSE)
prop@general$title
#> [1] "Local bird diversity (cSAR/BES-SIM)"They are two different published datasets, which can be easy to miss.
The file bundled inside ebvcube is a spatial subset of Local bird diversity (cSAR/BES-SIM), portal id = 1. The dataset this tutorial follows is Global trends in biodiversity (BES-SIM cSAR-iDiv), portal id = 30. They share a lead author and a model family, which is why the names look so similar, but they are separate published products: id = 1 covers 1900–2015 with no scenarios, while id = 30 covers 1900, 2015 and 2050 across three SSP×RCP scenarios.
We use the bundled file here and only here, because verifying an installation should not depend on a working internet connection. The tutorial’s scenario-based reference dataset is id = 30.
If the title prints, your installation is working. You can then optionally download the tutorial’s scenario-based reference dataset from the portal (≈ 3.3 MB). This second check requires an internet connection:
file <- ebv_download(id = 30, outputdir = tempdir(), overwrite = FALSE)
prop <- ebv_properties(file, verbose = FALSE)
prop@general$title
#> [1] "Global trends in biodiversity (BES-SIM cSAR-iDiv)"Checkpoint. Your setup is complete when library(ebvcube) loads without error and ebv_properties() prints the title of the bundled dataset. Downloading id = 30 is an optional connectivity check. Once the installation check works, you are ready to prepare biodiversity data in Unit 3.