##Set default repo to fix the issue when publishing html
local({r <- getOption("repos")
       r["CRAN"] <- "http://cran.r-project.org" 
       options(repos=r)
})

1. Lesson 1


install.packages("shiny")             # Install the Shiny package
install.packages("shinydashboard")    # Install the shinydashboard package
install.packages("flexdashboard")     # Install the flexdashboard package

# Load the packages.
library("shiny")
library("shinydashboard")
library("flexdashboard")

Online Retail II Data Set (This Online Retail II data set contains all the transactions occurring for a UK-based and registered, non-store online retail between 01/12/2009 and 09/12/2011.The company mainly sells unique all-occasion gift-ware. Many customers of the company are wholesalers). Reference: https://archive.ics.uci.edu/ml/datasets/Online+Retail+II

  1. Invoice: Invoice number. Nominal. A 6-digit integral number uniquely assigned to each transaction. If this code starts with the letter ‘c’, it indicates a cancellation.
  2. StockCode: Product (item) code. Nominal. A 5-digit integral number uniquely assigned to each distinct product.
  3. Description: Product (item) name. Nominal.
  4. Quantity: The quantities of each product (item) per transaction. Numeric.
  5. InvoiceDate: Invice date and time. Numeric. The day and time when a transaction was generated.
  6. Price: Unit price. Numeric. Product price per unit in sterling (£).
  7. CustomerID: Customer number. Nominal. A 5-digit integral number uniquely assigned to each customer.
  8. Country: Country name. Nominal. The name of the country where a customer resides.

California Housing Prices Data Set (The data pertains to the houses found in a given California district and some summary stats about them based on the 1990 census data). Reference: https://www.kaggle.com/camnugent/california-housing-prices

  1. longitude: A measure of how far west a house is; a higher value is farther west
  2. latitude: A measure of how far north a house is; a higher value is farther north
  3. housingMedianAge: Median age of a house within a block; a lower number is a newer building
  4. totalRooms: Total number of rooms within a block
  5. totalBedrooms: Total number of bedrooms within a block
  6. population: Total number of people residing within a block
  7. households: Total number of households, a group of people residing within a home unit, for a block
  8. medianIncome: Median income for households within a block of houses (measured in tens of thousands of US Dollars)
  9. medianHouseValue: Median house value for households within a block (measured in US Dollars)
  10. oceanProximity: Location of the house w.r.t ocean/sea. Five options: <1H OCEAN (less than a one hour drive to the ocean), INLAND, ISLAND, NEAR BAY, and NEAR OCEAN.

Import the datasets.


1.1 What is Shiny


  • Shiny is an R package that makes it easy to build interactive web apps straight from R. You can host standalone apps on a webpage or embed them in R Markdown documents or build dashboards.

    Figure: Shiny combines the computational power of R with the interactivity of the modern web

  • Shiny provides an elegant and powerful web framework for building web applications using R. Shiny helps you turn your analysis into interactive web applications without requiring HTML, CSS, or JavaScript knowledge.

  • Shiny’s user interface components can be easily customized or extended, and its server uses reactive programming to let you create any type of back-end logic you want. The back-end is the code that runs on the server, that receives requests from the clients, and contains the logic to send the appropriate data back to the client.


1.2 Components of Shiny



1.3 Components and features of shinydashboard



1.4 Differences between flexdashboard and shinydashboard



1.5 shinydashboard makes it easy to use Shiny to create dashboards



1.5.1 Basic dashboard



1.5.2 Interactive dashboard