Installing R and RStudio

You can download it free from the CRAN if you haven't installed R on your computer yet. Follow this link to the download page:

An IDE, or Integrated Development Environment, is a software application that provides a comprehensive environment for programmers to write, edit, and debug code. RStudio is a popular and powerful IDE developed for R by Posit. RStudio makes using R much easier, especially for beginners. The R console and environment are seamlessly integrated into RStudio so you can run R code and see plots, output, and results. RStudio also comes pre-installed with packages and functions to help you be more productive with R.

Datasets

You can download requred datasets using the following links.

Exercises

  1. Akbar, Sarah, Ali, and Nastaran all ran different distances in different time intervals. Their distances (in km) and times (in minutes) are as follows:
    name <- c("Akbar", "Sarah", "Ali", "Nastaran")
    distance <- c(0.8, 3.1, 2.8, 4.0)
    time <- c(10, 30, 40, 50)
    

    Write a line of code to convert time to hours. Then write a line of code to calculate the speed of each runner in km per hour (Speed is distance divided by time). Who was the fastest runner?

  2. Create a table, call it my_states, that satisfies both the conditions: it is in the Northeast or West and the murder rate is less than 1. Use “select” to show only the state name, the rate and the rate. How many states are in these regions?

RMarkdown

{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)

library(tidyverse)
library(ggthemes)
library(ggrepel)
library(ggthemes)