Introduction to R

Ermias Amene

February 12, 2025

Course Outline

Purpose of this Training

Requirement

Expectation

Getting Started

Installation instruction

Datasets

The following datasets are used throughout this training:

- Subset of the 2020 MPHIA data 

- Subset of data downloaded from DATIM

- Subset of [HIV/AIDS Surveillance Data Base downloaded from (https://www.census.gov/programs-surveys/international-programs/about/hiv.html)

Opening R:

R Panels

It has four parts/tabs with the following default appearance:

- Text editor/command prompt (top left window): commands are typed here and sent to the console

- Console (bottom left window): where you can type commands and see outputs

- Workspace/RStudio Environment Pane (right top window): displays active objects (data, functions etc.)

- Files tab (right bottom window): shows all files and folders including plots, packages etc.
   

R Panels

Note: The position can be rearranged

- Go to: Tools > Global Options > Pane Layout and then You can drag and move

- You can also change the color and font of display text (Tools > Global Options >

  Appearance > select whichever style you like > Apply > OK)
  

Creating a logbook

- Creating a logbook helps to document and save all your work.

How to create a logbook:

- File > New File > R Script >#  From the new window > File > Save As.. 

How to submit commands:

- put the cursor on the code/ or highlight the code and click 'Run'  

- put the cursor on the code/ or highlight the code and Press Ctrl + Enter



NOTE: THERE ARE SEVERAL WAYS OF DOING THE SAME TASK IN R!! Choose the easiest and most efficient



R Packages/ libraries

How to install R Packages?

- CRAN: majority of the packages are in CRAN<br>

 install.packages("PackageName")

- Github<br>
install_github("PackageName")

Lets go to RStudio cloud…


Introduction to R - Posit Cloud