HW2
21-3-17
Chapter 1 Prerequisites
Adarsuren, Sanai major; psychology 2087050
# Code chunk 1 for HW1
# head() is a function in base-R that display only the first 6 observations
head(iris)
# Code chunk 2 for HW1
# tidying the raw data into the tidy data using `pivot_longer()` and `separate()` functions in the tidyr package
library(tidyverse)
%>%
iris pivot_longer(cols = -Species, names_to = "Part", values_to = "Value") %>%
separate(col = "Part", into = c("Part", "Measure"))
# Code chunk 3 for HW1
# transforming our data using `group_by()` and `summarize()` functions in the dplyr package
# Because we created the `Part` variable in our tidy data,
# we can easily calculate the mean of the `Value` by `Species` and `Part`
# Code chunk 4 for HW1
# visualizing our data using `ggplot()` function in the `ggplot2` package
%>%
iris pivot_longer(cols = -Species, names_to = "Part", values_to = "Value") %>%
separate(col = "Part", into = c("Part", "Measure")) %>%
ggplot(aes(x = Value, color = Part)) + geom_boxplot()
-level heading `#`.
Remember each Rmd file contains one and only one chapter, and a chapter is defined by the first
TinyTeX (which includes XeLaTeX): <https://yihui.org/tinytex/>. To compile this example to PDF, you need XeLaTeX. You are recommended to install