library(tidyverse)
library(patchwork)
q <- 0
library(readr)
steak_risk_survey <- read_csv("steak-risk-survey.csv")
steak_data <-
filter(steak_risk_survey, `How do you like your steak prepared?` != "N/A" &
`How do you like your steak prepared?` != "Response") |> # these are taking out the people who answered no to eating steak along with a group response that presents itself when you graph the data.
group_by(`How do you like your steak prepared?`) |>
summarize(Count = n()) |>
mutate(Percentage = (Count / sum(Count)) * 100) #creating the percentage column using mutate with counts/sum counts.
ggplot(steak_data, aes(x = `How do you like your steak prepared?`, y = Percentage, fill = `How do you like your steak prepared?`)) +
geom_bar(stat = "identity", width = .7) +
scale_fill_manual(values = c(
"#D2691E", # Medium
"#F4A460", # Medium-rare
"#A0522D", # Medium-well
"#FF7F50", # Rare
"#7B3F00" # Well
# i dont know how to order the categories in the y axis simimlar to the orginal(not possible without changing the data in some way, to obtain a specific order), so I just chose colors for the different doneness
)) +
scale_y_continuous(limits = c(0, 45))+
coord_flip() +
geom_text(aes(label = paste0(round(Percentage), "%")), hjust = -0.1, size = 4) +
labs(
title = "'How Do You Like Your Steak Prepared?'",
subtitle = "From a survey of 432 steak-eating Americans",
x = NULL,
y = NULL
) +
theme_minimal() +
theme(
plot.title = element_text(face = "bold", size = 16),
axis.text.y = element_text (size = 12, color = "black"),
axis.text.x = element_blank(),
axis.ticks = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_rect(fill = "grey90", color = NA),
plot.background = element_rect(fill = "grey90", color = NA),
legend.position = "none"
)
library(tidyverse)
steak_data <-
filter(steak_risk_survey, `How do you like your steak prepared?` != "N/A" &
`How do you like your steak prepared?` != "Response") |>
group_by(`How do you like your steak prepared?`) |>
summarize(Count = n()) |>
mutate(Percentage = (Count / sum(Count)) * 100) |>
arrange(desc(Percentage))
# I used the arrange to arrange descend in percentage value, and used the reorder in the x to have a flow decreasing by percentage. Due to this beings inside aes, this doesnt change the data in any way, just an aestetic thing.
ggplot(steak_data, aes(x = reorder(`How do you like your steak prepared?`, Percentage), y = Percentage, fill = Percentage)) +
geom_bar(width = 0.7, stat = "identity") +
geom_text(aes(label = paste0(round(Percentage), "%")), hjust = -0.1, size = 4) +
scale_fill_gradient(low = "#FFDAB9", high = "#8B0000") +
scale_y_continuous(limits = c(0, 45))+
coord_flip() +
labs(
title = "'How Do You Like Your Steak Prepared?'",
subtitle = "From a survey of 432 steak-eating Americans",
caption = "Data Source: SurveyMonkey",
x = NULL,
y = NULL
) +
theme_minimal() +
theme(
plot.title = element_text(face = "bold", size = 16),
plot.subtitle = element_text(size = 12),
axis.text.y = element_text(size = 12, color = "black")) +
theme_light()
I went to the FiveThirtyEight site and looked at the article “How Americans Like their Steak”, link. This was a pretty cool article, but the data contained lots of other information, like things youve done in your like, your views and other information. There was a question that asked if you ate steak, and if you did, how did you like it cooked. Later in the article, there was a bargraph displaying the results from the people who answered yes to eating steak. The original graph effectively visualizes the survey results on steak preparation preferences. It uses a horizontal bar chart to display the percentages for each category, making it easy to compare preferences across the options. The graph uses a horizontal bar graph orientation, which is ideal for displaying categorical data with long category names. While each bar has a distinct color, helping to visually separate the categories. I felt like in the original graph, the order of the catergorical variable(how do you like your steak prepared) goes in order from least cooked to most cooked from top to bottom. I was not able to do this in my recreation without manipulating the data in some way. In doing this, the bars are in random order and jump from high to low percentages randomly. In my improvement graph, I ordered the aestetics to arrange the percentages descending, so that there is a flow to the graph that can be followed. In the original graph, the colors kind of represented the color of the preparation of the steak, like rare is red, medium is a little darker, while well was really dark. This was not bad, but I didn’t feel like those colors fit well with one another, and kinda made it hard to flow. So I created a color scale gradient, that starts light and ends dark, with distinct colors in between, which also creates a flow from top to bottom or vice versa. I wanted to “Use color meaningfully and with restraint that tells a story”(from slide04). I wanted to take heed to in class discussions on simplicity, and enhancing interpretability:
This is my project 1.