#city wise temperature analysis St. Louis , Miss
require(ggplot2)
require(data.table)
require(knitr)
#install.packages("insol")
#install.packages("solaR")
# install.packages("sunshine") un available since 3.3.2
# require(sunshine)
require(solaR)
require(insol)df <- fread("C:/Users/vivek/Documents/GlobalLandTemperatures/GlobalLandTemperaturesByCity.csv",showProgress = TRUE)##
Read 2.2% of 8599212 rows
Read 6.7% of 8599212 rows
Read 11.2% of 8599212 rows
Read 15.6% of 8599212 rows
Read 20.1% of 8599212 rows
Read 24.5% of 8599212 rows
Read 29.0% of 8599212 rows
Read 33.4% of 8599212 rows
Read 37.3% of 8599212 rows
Read 41.6% of 8599212 rows
Read 46.2% of 8599212 rows
Read 50.5% of 8599212 rows
Read 55.0% of 8599212 rows
Read 59.5% of 8599212 rows
Read 64.0% of 8599212 rows
Read 68.5% of 8599212 rows
Read 72.9% of 8599212 rows
Read 77.3% of 8599212 rows
Read 81.8% of 8599212 rows
Read 86.2% of 8599212 rows
Read 90.4% of 8599212 rows
Read 94.8% of 8599212 rows
Read 99.1% of 8599212 rows
Read 8599212 rows and 7 (of 7) columns from 0.496 GB file in 00:00:25
df <- df[City=="Saint Louis"]
df<-df[Country =="United States"]
# doing above because there is another St.Louis even in Senegal!!
# Remove the missing values
df <- na.omit(df)
kable(df[1:5,1:7])| dt | AverageTemperature | AverageTemperatureUncertainty | City | Country | Latitude | Longitude |
|---|---|---|---|---|---|---|
| 1743-11-01 | 4.766 | 2.385 | Saint Louis | United States | 39.38N | 89.48W |
| 1744-04-01 | 13.778 | 2.428 | Saint Louis | United States | 39.38N | 89.48W |
| 1744-05-01 | 17.657 | 2.233 | Saint Louis | United States | 39.38N | 89.48W |
| 1744-06-01 | 23.067 | 2.078 | Saint Louis | United States | 39.38N | 89.48W |
| 1744-07-01 | 24.699 | 1.941 | Saint Louis | United States | 39.38N | 89.48W |
# Format the date field
df <- df[,dt:=as.Date(dt,"%Y-%m-%d")]ggplot(df,aes(x=dt,y=AverageTemperature,colour=reorder(Month.String,-AverageTemperature,mean)))+
geom_point()+
geom_smooth(method="loess")+
labs(title="Average Temperatures by Month in St.Louis",
x="Year",
y="Average Temperature",
colour="Month") As expected the June July August are the Hottest months, while February, December and January are coldest. There is a slight upward gradient in the Average temperatures in St.Louis.
#temp uncertainity
ggplot(df,aes(x=dt,y=AverageTemperatureUncertainty))+
geom_point(shape=1)+
geom_smooth(method="loess")+
labs(title="Average Temperature Uncertainty Over Time In St,Louis",
x="Year",
y="Average Temperature Uncertainty")The decrease in average uncertainity, can be attributed to availability in reliable technology for the accurate collection and measurement of sensor data.
#closeup
ggplot(df[Year>1913,], aes(x=AverageTemperatureUncertainty)) +
geom_density()+
labs(title="Density Plot of Temperature Uncertainty: St.Louis : 1913-Present")