Visualizing Sales of Eggs
For this analysis I’m chosing dataset poultry_tidy.csv from our classroom. I begin by loading in the dataset using the read_csv() function in the tidyverse.
library(knitr)
library(tidyverse)
data <- read_csv("/Users/shrutishelke1999/Downloads/poultry_tidy - poultry_tidy.csv")
head(data)
# A tibble: 6 × 4
Product Year Month Price_Dollar
<chr> <dbl> <chr> <dbl>
1 Whole 2013 January 2.38
2 Whole 2013 February 2.38
3 Whole 2013 March 2.38
4 Whole 2013 April 2.38
5 Whole 2013 May 2.38
6 Whole 2013 June 2.38
The dataset includes four columns- Product for the kind of eggs, the year and month in which they are sold and the prices in dollars. Let’s begin by looking at the year in which the most sale of eggs happened.
library(ggthemes)
ggplot(production_max, aes(Year,Price_Dollar)) +
geom_col() +
labs(x = "Year of Production", y = "Price of eggs in Dollars", title = "Selling of Eggs by Year")+
theme_minimal()
In the plot above, we see that the highest sale of eggs happened in the year 2012. To build a step further, let’s group our plot by the kinds of eggs that were sold during the years.
ggplot(production_max, aes(Year,Price_Dollar, color = Product)) +
geom_col() +
labs(x = "Year of Production", y = "Price of eggs in Dollars", title = "Selling of Eggs by Year")+
theme_minimal()
Text and figures are licensed under Creative Commons Attribution CC BY-NC 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".
For attribution, please cite this work as
Shelke (2022, May 19). Data Analytics and Computational Social Science: Blog Post 4. Retrieved from https://github.com/DACSS/dacss_course_website/posts/httpsrpubscomsshelke901513/
BibTeX citation
@misc{shelke2022blog, author = {Shelke, Shruti}, title = {Data Analytics and Computational Social Science: Blog Post 4}, url = {https://github.com/DACSS/dacss_course_website/posts/httpsrpubscomsshelke901513/}, year = {2022} }