Following instructions have been given for the assignment -
The Interactive Plots presented in this Assignment are as follows -
library(datasets)
library(plotly)
library(reshape2)
data("airquality") ## Load the airquality dataset
airquality$Month=as.factor(airquality$Month) ## Convert Month to factor
head(airquality)## Ozone Solar.R Wind Temp Month Day
## 1 41 190 7.4 67 5 1
## 2 36 118 8.0 72 5 2
## 3 12 149 12.6 74 5 3
## 4 18 313 11.5 62 5 4
## 5 NA NA 14.3 56 5 5
## 6 28 NA 14.9 66 5 6
ozone_daily=airquality[,c(1,5,6)] ## Extract Ozone, Month and Day columnsplot_ly(data = ozone_daily,x = ~Month, y = ~Day, z = ~Ozone, type="heatmap")library(datasets);library(plotly);library(reshape2)
data("airquality") ## Load the airquality dataset
airquality$Month=as.factor(airquality$Month) ## Convert Month to factor
ozone_daily=airquality[,c(1,5,6)] ## Extract Ozone, Month and Day columns
## Convert Long format to Wide for input to Heatmap
ozone_daily=dcast(ozone_daily,Day~Month,value.var = "Ozone")
ozone_daily=as.matrix(ozone_daily[,-1]) ## Convert to Matrix
colnames(ozone_daily)=c("May","June","July","August","September")plot_ly(z=ozone_daily,colorscale="Hot",x=colnames(ozone_daily), type="heatmap",colorbar = list(title = "Ozone Levels (parts per billion)"))%>%layout(title = "Daily Ozone Levels in New York, May to September 1973",xaxis = list(title = "Month"),yaxis = list(title = "Day"))library(datasets)
library(plotly)
data(uspop) ## Load the data set that gives the population of the United States
## (in millions) as recorded by the decennial census for the period 1790–1970.plot_ly(x=~time(uspop),y=~uspop,type="scatter",mode="lines") %>% layout(title = "U.S. Population in millions for the period 1790-1970",xaxis = list(title = "Year"),yaxis = list(title = "U.S. Population (millions)"))library(datasets)
library(plotly)
data(uspop) ## Load the data set that gives the population of the United States in millions for the period 1790-1970plot_ly(x=~time(uspop),y=~uspop,type="scatter",mode="lines") %>% layout(title = "U.S. Population in millions for the period 1790-1970", xaxis = list(title = "Year"),yaxis = list(title = "U.S. Population (millions)"))