library(tidyverse)
cars <- read_csv("data/cars.csv")
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.
ggplot(data = cars) +
geom_point(mapping = aes(x = displ, y = hwy))
ggplot(data = cars, mapping = aes(x = displ)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
average_cty <- mean(cars$cty)
(average_cty)
## [1] 16.85897