**Focus**: ggplot2, factors, strings, dates 18. Identify variable(s) which should be factors and transform their type in
Posted: Fri May 20, 2022 11:39 am
**Focus**: ggplot2, factors, strings, dates
18. Identify variable(s) which should be factors and transform
their type into a factor variable.
19. Create a new variable: Read about `cut_number()` function
using Help and add a new variable to the dataset `calories_type`.
Use `calories` variable for `cut_number()` function to split it
into 3 categories `n=3`, add labels `labels=c("low", "med",
"high")` and make the dataset ordered by arranging it according to
calories. Do not forget to save the updated dataset.
20. Create a dataviz that shows the distribution of
`calories_type` in food items for each type of restaurant. Think
carefully about the choice of data viz. Use facets, coordinates and
theme layers to make your data viz visually appealing and
meaningful. Use factors related data viz functions.
21. Add a new variable that shows the percentage of `trans_fat`
in `total_fat` (`trans_fat`/`total_fat`). The variable should be
named `trans_fat_percent`. Do not forget to save the updated
dataset.
22. Create a dataviz that shows the distribution of `trans_fat`
in food items for each type of restaurant. Think carefully about
the choice of data viz. Use facets, coordinates and theme layers to
make your data viz visually appealing and meaningful.
23. Calculate and show the average (mean) `total_fat` for each
type of restaurant. No need to save it as a variable.
24. And create a dataviz that allow to compare different
restaurants on this variable (`total_fat`). You can present it on
one dataviz (= no facets). Think carefully about the choice of data
viz.
Use coordinates and theme layers to make your data viz visually
appealing and meaningful. Save your file as .rmd Pull-commit-push
it to github
18. Identify variable(s) which should be factors and transform
their type into a factor variable.
19. Create a new variable: Read about `cut_number()` function
using Help and add a new variable to the dataset `calories_type`.
Use `calories` variable for `cut_number()` function to split it
into 3 categories `n=3`, add labels `labels=c("low", "med",
"high")` and make the dataset ordered by arranging it according to
calories. Do not forget to save the updated dataset.
20. Create a dataviz that shows the distribution of
`calories_type` in food items for each type of restaurant. Think
carefully about the choice of data viz. Use facets, coordinates and
theme layers to make your data viz visually appealing and
meaningful. Use factors related data viz functions.
21. Add a new variable that shows the percentage of `trans_fat`
in `total_fat` (`trans_fat`/`total_fat`). The variable should be
named `trans_fat_percent`. Do not forget to save the updated
dataset.
22. Create a dataviz that shows the distribution of `trans_fat`
in food items for each type of restaurant. Think carefully about
the choice of data viz. Use facets, coordinates and theme layers to
make your data viz visually appealing and meaningful.
23. Calculate and show the average (mean) `total_fat` for each
type of restaurant. No need to save it as a variable.
24. And create a dataviz that allow to compare different
restaurants on this variable (`total_fat`). You can present it on
one dataviz (= no facets). Think carefully about the choice of data
viz.
Use coordinates and theme layers to make your data viz visually
appealing and meaningful. Save your file as .rmd Pull-commit-push
it to github