I'm trying to figure out how to highlight the "blue chips" bar in a bar chart. Please explain in the simplest way you can I am new to r. I am trying to make blue chips blue and everything else red.
library(readr)
library(dplyr)
library(tidyr)
library(stringr)
library(lubridate)
library(reprex)
library(tidyverse)
library(quantreg)
library(ggplot2)
sports_top25000 <- read.csv('index_sales_export_categories.csv') %>%
select(graded_title, vcp_card_grade_id, category, year, date, price) %>%
group_by(graded_title,vcp_card_grade_id,year) %>%
summarise(Market_Cap = sum(price),Average_Price = mean(price),count=n(),
Standard_Deviation = sd(price),SD_over_Price = (Standard_Deviation/Average_Price))
sports_top25000
sports_SD_over_Price <- sports_top25000$SD_over_Price
mean_sports_SD_over_Price <- mean(sports_SD_over_Price)
SD_over_Price_df <- data.frame("Card Type" = c("Blue Chips",
"All Sports",
"Baseball",
"Basketball",
"Football",
"Hockey",
"Michael Jordan",
"Mickey Mantle",
"Modern Baseball",
"Modern Basketball",
"Modern Football",
"Postwar Baseball",
"Postwar Hockey",
"Prewar Baseball",
"Prewar Hockey",
"Vintage Basketball",
"Vintage Football"),
"Variability" = c(mean_blue_chips_sd_over_avg,
mean_sports_SD_over_Price,
mean_baseball_SD_over_Price,
mean_basketball_SD_over_Price,
mean_football_SD_over_Price,
mean_hockey_SD_over_Price,
mean_michael_jordan_basketball_SD_over_Price,
mean_mickey_mantle_baseball_SD_over_Price,
mean_modern_baseball_SD_over_Price,
mean_modern_basketball_SD_over_Price,
mean_modern_football_SD_over_Price,
mean_postwar_baseball_SD_over_Price,
mean_postwar_hockey_SD_over_Price,
mean_prewar_baseball_SD_over_Price,
mean_prewar_hockey_SD_over_Price,
mean_vintage_basketball_SD_over_Price,
mean_vintage_football_SD_over_Price),
stringsAsFactors = FALSE)
SD_over_Price_df <- SD_over_Price_df[order(SD_over_Price_df$Variability),]
SD_over_Price_df$Card.Type <- factor(SD_over_Price_df$Card.Type, levels = SD_over_Price_df$Card.Type)
head(SD_over_Price_df)
variability_of_sales_bar_chart <- ggplot(SD_over_Price_df, aes(x = Card.Type, y=Variability, fill=area)) +
geom_bar(stat = "identity", width=.5) +
scale_fill_manual(values=c("blue","red","red","red","red","red","red","red","red","red","red","red","red","red""red","red")) +
labs(title = "Variability of Different Card Types") +
theme(axis.text.x = element_text(angle = 65, vjust = 0.6))
plot(variability_of_sales_bar_chart)