This file contains a set of tasks that you need to complete in R for the lab assignment. The tasks may require you to add a code chuck, type code into a chunk, and/or execute code. Don’t forget that you need to acknowledge if you used any resources beyond class materials or got help to complete the assignment.
Additional information, include examples and code, about this assignment can be found in the file “VisualizingDistributionsTutorial.html”.
The data set you will use is different than the one used in the instructions. Pay attention to the differences in the Excel files’ names, any variable names, or object names. You will need to adjust your code accordingly.
Once you have completed the assignment, you will need to knit this R Markdown file to produce an .html file. You will then need to upload the .html file and this .Rmd file to AsULearn.
The first thing you need to do in this file is to add your name and date in the lines underneath this document’s title (see the code in lines 9 and 10).
You need to identify and set your working directory in this section. If you are working in the cloud version of RStudio, enter a note here to tell us that you did not need to change the working directory because you are working in the cloud. >setwd(“/Users/corddoss/Desktop/Research methods class/Week 8/8 Assignment Visualizing Distributions”)
You load the packages and data set you’ll use for the lab assignment
in this section. In this lab we will use the packages:
dplyr, tidyverse, forcats,
ggplot2, and openxlsx. > library(“dplyr”)
> library(“tidyverse”) > library(“openxlsx”) >
library(“forcats”) > library(“ggplot2”) > VisualizingVariablesData
<- read.xlsx(“VisualizingVariablesData.xlsx”) # 4. Histogram of Price
for Plate of Ribs Create a histogram showing the distribution of the
variable measuring the price someone would pay for a plate of
ribs.
ggplot(VisualizingVariablesData, #data argument
aes(x=Dinner.Plate.Price)) + #mapping and aesthetics arguments
geom_histogram() #geom argument - Change the labels on the x- and y-
axes to words instead of using the variable name. Make sure that the
labels on both the x- and y-axes are capitalized.
ggplot(VisualizingVariablesData, aes(x=Dinner.Plate.Price)) +
geom_histogram(fill=“red”) +
labs(x=“Dinner Plate Price”, y=“Count”)
Change the color of the bars to magenta.
>ggplot(VisualizingVariablesData, aes(x=Dinner.Plate.Price)) +
geom_histogram(fill=“darkmagenta”) +
labs(x=“Dinner Plate Price”, y=“Count”)
The plot should have 15 bins.
There should be no background color, but you should retain the x-
and y-axes. >ggplot(VisualizingVariablesData,
aes(x=Dinner.Plate.Price)) +
geom_histogram(fill=“red”) +
labs(x=“Dinner Plate Price”,
y=“Count”) + theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), panel.background = element_blank(),
axis.line = element_line())
Create a histogram showing the distribution of the variable measuring the minutes someone is willing to drive for BBQ. ggplot(VisualizingVariablesData, #data argument aes(x=driving)) + #mapping and aesthetics arguments geom_histogram() #geom argument - Change the labels on the x- and y-axes to words instead of using the variable name. Make sure that the labels on both the x- and y-axes are capitalized.
Change the color of the bars to violet.
The plot should have 25 bins.
There should be no background color but you should retain the x-and y-axes.
Create a density plot showing the distribution of the variable measuring minutes someone is willing to drive for BBQ.
Change the labels on the x- and y-axes to words instead of using the variable name. Make sure that the labels on both the x- and y-axes are capitalized.
Change the color of the line to lightblue4, and the color underneath the line to lightblue1.
The type of the line should be “twodash”.
There should be no background color but you should retain the x- and y-axes.
Add a vertical line at the mean of the variable.
Create a density plot showing the distribution of the variable measuring the price someone is willing to pay for a pulled pork sandwich.
Change the labels on the x- and y- axes to words instead of using the variable name. Make sure that the labels on both the x- and y-axes are capitalized.
Change the color of the line to springgreen4, and the color underneath the line to springgreen1.
The type of the line should be “longdash”.
There should be no background color but you should retain the x and y axes.
Add a vertical line at the mean of the variable.
Create a box-and-whisker plot of the variable measuring the price someone is willing to pay for a pulled pork sandwich.
The color of the box should be azure1 and the color of the outline of the box should be blue. >ggplot(VisualizingVariablesData, aes(x=Dinner.Plate.Price)) + geom_boxplot(fill = “azure1”, colour = “blue”)
The color of the outliers should be darkcyan and the shape of the
outliers should be a *.
>ggplot(VisualizingVariablesData, aes(x=Dinner.Plate.Price)) +
geom_boxplot(fill = “azure1”, colour = “blue”, outlier.colour =
“darkcyan”, outlier.shape = 1)
The orientation of this graph should be horizontal.
Make the appropriate adjustments to the labels, text, and tick marks for the x- and y-axis based on the orientation of the graph.
There should be no background color.
>ggplot(VisualizingVariablesData, aes(x=Dinner.Plate.Price)) +
geom_boxplot(fill = “azure1”, colour = “blue”, outlier.colour =
“darkcyan”, outlier.shape = 1) + labs(x=“Dinner Plate Price”, y=““) +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), panel.background = element_blank(),
axis.line = element_line(), axis.text.y = element_blank(), axis.ticks.y
= element_blank())
Create a box-and-whisker plot of the variable measuring the minutes someone is willing to drive for BBQ.
The color of the box should be lightsteelblue1 and the color of the outline of the box should be lightsteelblue4. >ggplot(VisualizingVariablesData, aes(x=Dinner.Plate.Price)) + geom_boxplot(fill = “lightsteelblue1”, colour = “lightsteelblue4”)
The color of the outliers should be mediumpurple4 and the shape
of the outliers should be an empty diamond.
>ggplot(VisualizingVariablesData, aes(x=Dinner.Plate.Price)) +
geom_boxplot(fill = “lightsteelblue1”, colour = “lightsteelblue4”,
outlier.colour = “mediumpurple4”, outlier.shape = 1) + labs(x=“Dinner
Plate Price”, y=““) + theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), panel.background = element_blank(),
axis.line = element_line(), axis.text.y = element_blank(), axis.ticks.y
= element_blank())
The orientation of this graph should be vertical.
Make the appropriate adjustments to the labels, text, and tick marks for the x- and y- axis based on the orientation of the graph.
There should be no background color.
>ggplot(VisualizingVariablesData, aes(x=Dinner.Plate.Price)) +
geom_boxplot(fill = “lightsteelblue1”, colour = “lightsteelblue4”,
outlier.colour = “mediumpurple4”, outlier.shape = 1) + labs(x=“Dinner
Plate Price”, y=““) + theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), panel.background = element_blank(),
axis.line = element_line(), axis.text.y = element_blank(), axis.ticks.y
= element_blank())
Enter the names of anyone one that assisted you with completing this lab. If no one helped you complete the assignment, just type out that no one helped you
Enter the names of anyone that you assisted with completing this lab. If you did not help anyone, then just type out that you didn’t help anyone.
Click the “Knit” button to publish your work as an html document. This document or file will appear in your working directory. You will need to upload both this RMarkdown file and the html file it produces to AsU Learn to get all of the lab points for this week.