Software and Packages

Installing R, RStudio, and Modern R Package

Masumbuko Semba

2024-01-25

The concept

  • The concept is based on five itmes—plan, simulate, acquire, explore and share

Learning Agenda

  1. Get familiar with R and Rstudio
  2. Data structure and data types
  3. Reading and writing data in Rstudio
  4. Tidying and Data manipulation with tidyverse
  5. Plotting and Visualization
  6. Descriptive Statistics
  7. Inferential Statistics
  8. Modelling and simulation
  9. Spatial Handling and Analysis

R and Rstudio Softwares

Installing R

  • R is a free and open-source statistical programming language and software environment.
  • To install R, visit the official R project website: https://cran.r-project.org/bin/windows/base/
  • Choose the appropriate installer for your operating system (Windows, macOS, Linux).
  • Run the installer and follow the on-screen instructions.

Warning

Make sure you download the latest version of R for optimal performance and compatibility

Installing Rstudio

  • RStudio is a popular integrated development environment (IDE) for R.
  • It provides a user-friendly interface for writing, editing, and running R code.
  • To install RStudio, visit the official RStudio website: https://posit.co/download/rstudio-desktop/
  • Choose the appropriate installer for your operating system (Windows, macOS, Linux).
  • Run the installer and follow the on-screen instructions.

Warning

The free desktop version of RStudio is sufficient for most users.

Note

The paid versions offer additional features like project management and collaboration tools.

Get familiar with Rstudio

Editor

  • Where you write your R code, like spells to command your data.
  • Use syntax highlighting for easier reading and error detection.
  • Run code line by line or in chunks to experiment and debug.

Note

Don’t forget to comment your code to revisit your data-wrangling magic later!

Console

  • See the output of your commands, like a printed echo of your data adventures.
  • Check results, error messages, and warnings to debug and learn.
  • Interact with R directly by entering commands on the fly.

Note

Use history() to recall past commands and avoid code retyping fatigue.

Environment

  • our workspace, where objects and variables you create reside.
  • View and inspect data objects, functions, and packages loaded.
  • Edit object values directly for quick exploration and tweaks.

Note

Use clear() to clean up your workspace and avoid data clutter confusion.

Plots Pane

  • Visualize your data in the Plots pane, transforming numbers into stunning stories.
  • The Viewer pane displays various object outputs, like tables and images.
  • Access R’s extensive documentation and community resources in the Help pane.

Note

Experiment with different plot types and customize them to tell your data’s unique story.

Thanks!

Slides created via the R packages: Quarto

The chakra comes from remark.js, knitr, and R Markdown.

Demo

Installing Packages

  • R has a vast ecosystem of packages that extend its functionality.
  • R packages are essential for data analysis, visualization, machine learning, and other tasks.

Warning

Warn against installing packages from untrusted or unofficial sources

Important

Emphasize the importance of verifying package sources to avoid security issues

Installing packages….

There are two main ways to install R packages

  1. From the CRAN repository: The CRAN repository is the official package repository for R. It contains over 24,000 packages.
  2. From GitHub: Many developers host their packages on GitHub. These packages are often cutting-edge and not yet available on CRAN.

Tip

The easiest way to install packages is from console using install.packages() function

References