Ermias
Amene
February 12, 2025
Purpose
Introduction
Getting
started
Creating/Setting
working directory
Arithmetic
Importing/Exporting
data
Data
Management
Tables
Graphics
This hands-on training introduces the free statistical program R as a
basic tool for conducting data analysis and visualization.
The course is not intended to cover detailed statistical tests, functions or advanced methods.
Basic
understanding of data and some data analysis
experience.
Experience using
other statistical programs is a plus but not
required.
We will use a cloud-based R program, so you do not need the program installed on your computer prior to the training.
However, you
need to have R and Rstudio installed in your laptop if you plan to
continue to use R after the training (instruction included in the course
folder).
Active
participation is expected
At
the end of the training, participants should:
Use their own data and will be able to interact with R programming environment
Import various types of data, conduct some data cleaning activity
Run some basic analysis and visualize results.
RStudio Cloud
will be used but it is highly encouraged to have a local version of R
and Rstudio installed in your laptop.
Exercises at the
end of each section should be completed using your cloud based R
program.
Request both R
and RStudio via CDC
SRT.
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)
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.
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 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: are a set of user written functions to perform several specific and general tasks.
A library is a directory into which the R package is stored. In order to access the package, the library has to be loaded first
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…