Introduction to R
Recursos Computacionais aplicados à Estatística e Experimentação
Agropecuária - PPG em Estatística e Experimentação
Agropecuária/UFLA
Prof. Izabela R. Cardoso de Oliveira
2023/1
The R Software
· R is a free software environment for statistical computing and graphics
· R is available as Free Software under the terms of the Free Software
Foundation’s GNU General Public License. It is open source code
· R was developed by Ross Ihaka and Robert Gentleman (Department of
Statistics, University of Auckland, NZ). R is now under the stewardship of
the R Project and the R Foundation
· R can be install on different operating systems: Windows, Mac and Linux
· Paper: Ihaka, R.; R. Gentleman (1996). R: A language for data analysis and
graphics. Journal of Computational and Graphical Statistics, 5, 299-314.
2/11
· IHAKA, R. R : Past and Future History. http://cran.r-
project.org/doc/html/interface98-paper/paper.html
· R provides a wide variety of statistical (linear and nonlinear modelling,
classical statistical tests, time-series analysis, classification, clustering, …)
and graphical techniques, and is highly extensible.
· R is an integrated suite of software facilities for data manipulation,
calculation and graphical display.
· For computationally-intensive tasks, C, C++ and Fortran code can be linked
and called at run time
3/11
Installing R
· https://www.r-project.org/
· The Comprehensive R Archive Network - CRAN: it is available at several
URLs (mirrors). It is recommended that we choose a closer location
https://cran.r-project.org/mirrors.html
· It can be found the same materials, R versions, extensions and documents
on each mirror
· When we install R, we are installing only a “core” and the Base packages. If
we want to use other packages, it is necessary to install and load the
package
4/11
R Packages
· R Base Packages: it is install together with R. This package contains the
basic functions which let R function as a language: arithmetic,
input/output, basic programming support, etc. Its contents are available
through inheritance from any environment.
· Examples of R Base Packages: base, datasets, graphics and stats
· A complete list of functions can be view by typing
library(help = "base")
5/11
R Packages
· Other packages: recommended and contributed
· Recommended packages: MASS, lattice, nlme, rpart, survival, spatial
· Contributed packages: 19,260 packages (Feb 27, 2023 - 4:52pm)
· Available packages: any mirror
· Installed and loaded packages
To view installed packages:
installed.packages()
To view loaded packages:
search()
6/11
R Packages
· To install a package: install.packages("package name") or menu
shortcuts.
· To load a package: library("package name") or require("package name")
library("tidyverse")
· To update a package: update.packages("package name")
· To update all installed packages: update.packages(ask=FALSE)
7/11
Citing R and R packages
· Citing R and R packages: it is needed to cite
· to cite R:
citation()
· To cite the package ggplot2
citation("ggplot2")
8/11
Needs help?
· Books
· Handouts
· R Documentation: Contributed documentation + mailing lists
· Functions help
· Google
· Stackoverflow: you can restrict your search by using [R]
(https://stackoverflow.com/)
· Short reference card, reference guides…
9/11
RStudio
· IDE: Integrated Development Environment for R
· It includes a console, syntax-highlighting editor that supports direct code
execution, as well as tools for plotting, history, debugging and workspace
management
· It is available in open source and commercial editions
· It runs on the desktop (Windows, Mac, and Linux) or in a browser
connected to RStudio Server or RStudio Workbench
· more complete and “user-friendly” interface
· It can be downloaded from http://www.rstudio.com/ and it must be install
in computers that already have the R installed
10/11
References
HORNIK, K. (2018), The R FAQ. https://CRAN.R-project.org/doc/FAQ/R-FAQ.html
MELLO, M. P.; PETERNELLI L. A. (2013) Conhecendo R: uma visão mais que
estatística. Viçosa, MG: Editora UFV.
11/11