This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
# Graph 1 - Bar Plot
ggplot(dat, aes(x = Date, y = Price)) +
geom_bar(stat = "identity", fill = "skyblue", color = "black") +
labs(title = "Bitcoin Prices Over Time (Bar Plot)", x = "Date(daily)", y = "Price(US)")
#Garph2
highlighted_points <- dat %>% filter(`Change %` >= 0.05)
# Plot with highlighted points
ggplot(dat, aes(x = Date, y = Price)) +
geom_point() +
geom_text(
data = highlighted_points,
aes(label = ifelse(is.numeric(`Change %`), round(`Change %`, 2), "")),
vjust = -0.5, hjust = 0.5, size = 3
) +
labs(title = "Bitcoin Prices Over Time", x = "Date", y = "Price")
cel$party<-recode(cel$dem,`1`="Democrat",`0`="Republican")
cong_dat<- cel %>%
group_by(year,party) %>%
summarise("Seats"=n())
## `summarise()` has grouped output by 'year'. You can override using the
## `.groups` argument.
anim2<-ggplot(cong_dat,aes(x=year,y=Seats,fill=party))+
geom_bar(stat="identity")+
geom_hline(yintercept=217)+
scale_fill_manual(values=c("yellow","darkgrey"))+
transition_time(year)
print(anim2)
cel %>% filter(congress==115) %>%
ggplot(aes(x=dwnom1,y=all_pass))+
geom_point()+
geom_text_repel(filter(cel,congress==115 & all_pass>10),mapping=aes(x=dwnom1,y=all_pass,label=thomas_num))+
annotate("rect",xmin=.05,xmax=.4,ymin=13,ymax=15,alpha=0.9,fill="yellow")+
annotate("text",x=.6,y=14,label="Top Change %",color="orange")+
labs(x = "Date", y = "Price")
## Warning: Removed 6 rows containing missing values (`geom_point()`).
fig_data <- cel %>%
group_by(party,year) %>%
summarize("Ideology"=mean(dwnom1,na.rm=T))
## `summarise()` has grouped output by 'party'. You can override using the
## `.groups` argument.
ggplot(fig_data, aes(x = year, y = Ideology, group = party, color = party)) +
geom_line() +
scale_color_manual(values = c("skyblue", "black")) +
labs(x = "Year", y = "Price") +
guides(color = FALSE)
## Warning: The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none" instead as
## of ggplot2 3.3.4.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
df <- data.frame(
year = rep(2000:2005, each = 2),
Ideology = rnorm(12),
Party = rep(c("A", "B"), times = 6))
ggplot(df, aes(x = year, y = Ideology, group = Party, color = Party)) +
geom_line() +
scale_color_manual(values = c("skyblue", "black")) +
labs(x = "Year", y = "Ideology") +
facet_wrap(~ Party, scales = "free_y")
#Graph7
filtered_dat1 <- dat %>% filter(Price > 65000)
ggplot(filtered_dat1, aes(x = Date, y = Price)) +
geom_bar(stat = "identity", fill = "skyblue", color = "skyblue") +
labs(title = "Bitcoin Prices Over 65000 US", x = "Date(day)", y = "Price(US)")
#Graph8
highlighted_points50per <- dat %>% filter(`Change %` >= 50)
highlighted_points60k <- dat %>% filter(Price > 60000)
# Plot with highlighted points (Price over 65000 us)
ggplot(dat, aes(x = Date, y = Price)) +
geom_point(data = highlighted_points50per, color = "darkgrey", size = 3) +
geom_point(data = highlighted_points60k, color = "red", size = 3) +
labs(title = "Bitcoin Prices Over Time", x = "Date", y = "Price")