install.packages("LIBRARY")
1 Getting Started with R
1.1 Your R System
In this course, we work with the combination of R + RStudio.
- R is the calculation engine (language and enviromnet) that performs the computations.
- RStudio is the editor (IDE) that helps you sending inputs to R and collect outputs.
Make sure you have a recent version of R + RStudio installed on your computer. If you have never used RStudio, here is a good video introducing the basic system and how R and RStudio interact.
1.2 Libraries that you will need
The R engine comes with a number of base functions, but one of the great things about R is that you can extend these base functions by libraries that can be programmed by anyone. In principle, you can install libraries from any website or file. In practice, however, most commonly used libraries are distributed via two major repositories. For statistical methods, this is CRAN, and for bioinformatics, this is ioconductor](https://www.bioconductor.org/).
To install a package from a library, use the command:
Exchange “LIBRARY” with the name of the library you want to install. The default is to search the package in CRAN, but you can specify other repositories or file locations in the function. For Windows / Mac, R should work out of the box. For other UNIX based systems, may also need to install
build-essential
gfortran
libmagick++-dev
r-base-dev
cmake
If you are new to installing packages on Debian / Ubuntu, etc., type the following:
sudo apt update && sudo apt install -y --install-recommends build-essential gfortran libmagick++-dev r-base-dev cmake
In this book, we will often use data sets from the EcoData
package, which is not on CRAN, but on a GitHub page. To install the package, if you don’t have the devtools package installed already, first install devtools from CRAN by running:
install.packages("devtools")
Then, install the EcoData package via:
::install_github(repo = "TheoreticalEcology/EcoData",
devtoolsdependencies = T, build_vignettes = T)
For your convenience, the EcoData installation also forces the installation of most of the packages needed in this book, so this may take a while. If you want to load only the EcoData package, or if you encounter problems during the install, set dependencies = F, build_vignettes = F
.
1.3 Extra resources
To get to know Rstudio better, here is the link for a brief tour from another “bookdown” page with simple and good explanations for each panel and the many resources.