A short description of the post.
The code below is my file path for importing the data regarding chicken meat prices in excel form
poultry <- read_excel("../../_data/poultry_tidy.xlsx")
poultry
# A tibble: 600 × 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
7 Whole 2013 July 2.38
8 Whole 2013 August 2.38
9 Whole 2013 September 2.38
10 Whole 2013 October 2.38
# … with 590 more rows
Below is my initial data table manipulation which I did to get a specific product, in this case boneless breast with its price and the year in which that price was observed
poultry %>% group_by(`Price_Dollar`)%>%
# first line groups the data by the price in the
#Price_Dollar column so the data in the column is sorted into chunks of the same price.
select(!(`Month`))%>%
# This select function selects all columns except for the one called "Month"
filter(Product=="B/S Breast") %>%
# The line above selects only the Product in the
#"Product" column called "B/S Breast, or boneless chicken breast"
arrange(desc(`Price_Dollar`)) %>%
# The above line sorts or arranges the column of
# Price in dollars or "Price_Dollar" in descending order
#starting above 7 dollars and going down closer to 6 dollars
rename(Chicken_Bonless_Breast_Price=Price_Dollar)
# A tibble: 120 × 3
# Groups: Chicken_Bonless_Breast_Price [8]
Product Year Chicken_Bonless_Breast_Price
<chr> <dbl> <dbl>
1 B/S Breast 2013 7.04
2 B/S Breast 2013 7.04
3 B/S Breast 2013 7.04
4 B/S Breast 2013 7.04
5 B/S Breast 2013 7.04
6 B/S Breast 2013 7.04
7 B/S Breast 2013 7.04
8 B/S Breast 2013 7.04
9 B/S Breast 2013 7.04
10 B/S Breast 2013 7.04
# … with 110 more rows
# This above line renames the column
#"Price_Dollar" into column "Chicken_Boneless_Breast_Price"
# The line above takes the poultry data frame, it then finds the mean price in dollars and removes all N/A observations
# A tibble: 1 × 1
`mean(Price_Dollar, na.rm = TRUE)`
<dbl>
1 3.39
The first line groups the data by the price in the Price_Dollar column so the data in the column is sorted into chunks of the same price.
The second line selects all columns except for the one called “Month”
The third line selects only the Product in the “Product” column called “B/S Breast, or boneless chicken breast”
The fourth line sorts or arranges the column of Price in dollars or “Price_Dollar” in descending order starting above 7 dollars and going down closer to 6 dollars This fifth line renames the column “Price_Dollar” into column “Chicken_Boneless_Breast_Price”
The final line of codes above takes the poultry data frame, it then finds the mean price in dollars and removes all N/A observations
poultry %>% group_by(Year, Price_Dollar, Product) %>% ggplot() + geom_smooth(mapping=aes(y=Price_Dollar, x=Year, color=Product), na.rm=TRUE)
By Noah Milstein
The graph above suggests that the price of most chicken cuts remain relatively similar over time, however B/S Breast or boneless chicken breast appears to have increased in price over recent years. Thighs have also remained relatively similar
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
Milstein (2021, Aug. 17). DACSS 601 August 2021: NoahHw3. Retrieved from https://mrolfe.github.io/DACSS601August2021/posts/2021-08-17-noahhw3/
BibTeX citation
@misc{milstein2021noahhw3, author = {Milstein, Noah}, title = {DACSS 601 August 2021: NoahHw3}, url = {https://mrolfe.github.io/DACSS601August2021/posts/2021-08-17-noahhw3/}, year = {2021} }