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:
Create a web page presentation using R Markdown that features a plot created with Plotly. Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document, and it must contain a plot created with Plotly.
Data Processing for Plot 1 - Heatmap R Code
library(datasets)
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(reshape2)
data("airquality")
airquality$Month = as.factor(airquality$Month)
ozone_daily = airquality[, c(1, 5, 6)]
ozone_daily = dcast(ozone_daily, Day ~ Month, value.var = "Ozone")
ozone_daily = as.matrix(ozone_daily[, -1])
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"))
Data Processing for Plot 2 : Time-Series Chart R Code
library(datasets)
library(plotly)
data(uspop)
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)"))