Loading data

library(tidyverse)

cars <- read_csv("data/cars.csv")

Learning R

In the primers, I learnt how to import a csv file in R so that it can be used for analysis. I also learned how to load other packages that enable R to plot graphs like the tidyverse. I have also learnt how to code using ggplot2 to load,clean and plot graphs.I have also learnt that when plotting a histogram using ggplot2 you don’t need the y variable.

My first plots

Creating a scatterplot

ggplot(data = cars) +
  geom_point(mapping = aes(x = displ, y = hwy))

Creating a histogram

ggplot(data = cars, mapping = aes(x = displ)) +
  geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Calculating the average of cty

average_cty <- mean(cars$cty)
(average_cty)
## [1] 16.85897