You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
linechart<-iot_data %>% group_by(day(date)) %>%
summarise(Avg_Temp_per_Day= round(mean(temperature), digits=2))
linechart<-linechart %>% ggplot(aes(`day(date)`,Avg_Temp_per_Day)) +
geom_line(color="mediumseagreen", size=0.8) + geom_point(color="red", size=0.8) +
xlab("Day of the Month") + ylab("Average Temperature") +
ggtitle("Daywise Avg. Temp. for the month of November") +
theme(legend.position="none")
linechart
HEAT MAP
heat_map<-iot_data %>% mutate(day= day(date), hour= hour(date)) %>%
group_by(day,hour) %>% mutate(Avg_Temp_per_day= mean(temperature))
library(grDevices)
colorsdefined<- colorRampPalette(c("skyblue","brown1"))(15)
heat_map<- ggplot(heat_map,aes(day,hour, fill= as.factor(Avg_Temp_per_day))) +
geom_tile() + xlab("Day of the month") + ylab("Hour of the Day") +
ggtitle("Hourly Temperature Readings for the month of November") +
scale_fill_manual(values=colorsdefined) + labs(fill="Temperature") +
theme(axis.text.x= element_text(angle=30),axis.text.y= element_text(angle=30))
heat_map
BOX PLOT
bplot<-iot_data %>% group_by(day(date)) %>% ggplot(aes(`day(date)`,temperature)) +
geom_boxplot(aes(group=`day(date)`, fill=factor(`day(date)`))) +
xlab("Day of the Month") + ylab("Temperature Distribution") +
ggtitle("Daywise Distribution of Temperature Readings") +
theme(legend.position="none") + scale_x_continuous(breaks= seq(1,30,1))
bplot
SCATTERPLOT
#Scatterplot with 2 Quantitative and 1 Categorical Variablescatter<- ggplot(tweets_data, aes(retweets_count,favorite_count, color=source)) +
geom_point(cex=0.8, pch=1.3, show.legend=T) + xlab("Retweets") + ylab("Likes") +
ggtitle("Retweets vs. Likes / Device Used") + theme(legend.position="top")
scatter
ANIMATED SCATTERPLOT
#install.packages("devtools")#devtools::install_github("dgrtwo/gganimate")
library(animation)
library(gganimate)
odi_data$YEAR<- year(mdy(odi_data$MatchDate))
odi_subset<-odi_data %>% filter(Player=="Sachin R Tendulkar")
#ImageMagick, or other such drivers need to be installed on your computer#Sys.setenv(PATH = paste("C:/Program Files/ImageMagick-7.0.7-Q16/", Sys.getenv("PATH"), sep = ";"))magickPath<- shortPathName("C:/Program Files/ImageMagick-7.0.7-Q16/magick.exe")
ani.options(convert=magickPath)
plot<- ggplot(odi_subset, aes(Runs, ScoreRate, frame=YEAR,
cex=ScoreRate, color="Red")) + geom_point() +
theme(legend.position="none") +
ylab("Strike Rate") +
ggtitle("Sachin's Centuries vs. Strike Rate over the years...")
gganimate(plot, interval=0.7)
TREE MAP
#Tree Map with 2 Categorical & 1 Quantitative Variable
library(treemap)
odi_data$Century=odi_data$Runs>99stadiums=odi_data %>% filter(Century==TRUE) %>% group_by(Player,Ground) %>%
summarise(`100's`= n()) %>% arrange(desc(`100's`)) %>% group_by(Ground) %>%
mutate(Total_Centuries_in_Stadium= sum(`100's`)) %>%
arrange(desc(Total_Centuries_in_Stadium)) %>% filter(Total_Centuries_in_Stadium>20)
treemap(stadiums, index= c("Total_Centuries_in_Stadium","Ground","Player"),
vSize="Total_Centuries_in_Stadium",
title="Stadiums with most number of ODI Centuries", palette="Greens")
FACET WRAP
Top_10_Players<-odi_data %>% group_by(Player) %>% summarise(TotalRuns= sum(Runs)) %>%
arrange(desc(TotalRuns)) %>% head(10)
odi_data$"100's"<- as.numeric(odi_data$Runs>99)
odi_data$Year<- year(mdy(odi_data$MatchDate))
Top_10_Players_data<-odi_data %>% filter(Player%in%Top_10_Players$Player) %>%
group_by(Player, Year) %>% summarise(Centuries= sum(`100's`))
f_wrap<- ggplot(Top_10_Players_data, aes(Year,Centuries, color=Player)) + geom_point() +
geom_line() + facet_wrap(~Player, nrow=5) + theme(legend.position="none") +
ggtitle("Centuries of Top 10 Run Scorers over the Years")
f_wrap
FACET GRID
Top_5_Players<-odi_data %>% group_by(Player) %>% summarise(TotalRuns= sum(Runs)) %>%
arrange(desc(TotalRuns)) %>% head(5)
Top_5_Players_data<-odi_data %>% filter(Player%in%Top_5_Players$Player) %>%
group_by(Player, Year) %>% summarise(Centuries= sum(`100's`))
f_grid<- ggplot(Top_5_Players_data, aes(Year,Centuries, color=Player)) + geom_jitter() +
geom_smooth(method="loess") + facet_grid(Player~.) + theme(legend.position="none") +
ggtitle("Centuries of Top 5 Run Scorers over the Years")
f_grid