Skip to content

Instantly share code, notes, and snippets.

@korkridake
Created November 30, 2018 11:18
Show Gist options
  • Save korkridake/3ef32891f468f472fba1fdc46e95d944 to your computer and use it in GitHub Desktop.
Save korkridake/3ef32891f468f472fba1fdc46e95d944 to your computer and use it in GitHub Desktop.
# load packages
library(shiny)
library(shinydashboard)
####################
# #
# Exercise 1 #
# #
####################
header <- dashboardHeader(
title = span(
"Practicing shinydashboard",
style = "font-family: Tahoma; font-weight: bold"
)
)
####################
# #
# Exercise 2 #
# #
####################
header <- dashboardHeader(
title = span(
"Practicing shinydashboard",
style = "font-family: Tahoma; font-weight: bold"
),
titleWidth = "300px"
)
sidebar <- dashboardSidebar(
width = "300px"
)
####################
# #
# Exercise 3 #
# #
####################
ui <- dashboardPage(
skin = "black",
header = header,
sidebar = sidebar,
body = body
)
####################
# #
# Exercise 4 #
# #
####################
ui <- dashboardPage(
skin = "black",
title = "R-Exercises",
header = header,
sidebar = sidebar,
body = body
)
####################
# #
# Exercise 5 #
# #
####################
sidebar <- dashboardSidebar(
width = "300px",
sidebarMenu(
menuItem(
text = span("Data", style = "font-size: 20px"),
tabName = "data"
),
menuItem(
text = span("About", style = "font-size: 20px"),
tabName = "about"
)
)
)
####################
# #
# Exercise 6 #
# #
####################
sidebar <- dashboardSidebar(
width = "300px",
sidebarMenu(
menuItem(
text = span("Data", style = "font-size: 20px"),
tabName = "data",
icon = icon("database")
),
menuItem(
text = span("About", style = "font-size: 20px"),
tabName = "about",
icon = icon("info-circle")
)
)
)
####################
# #
# Exercise 7 #
# #
####################
sidebar <- dashboardSidebar(
width = "300px",
sidebarMenu(
menuItem(
text = span("Data", style = "font-size: 20px"),
tabName = "data",
icon = icon("database"),
badgeLabel = "New",
badgeColor = "yellow"
),
menuItem(
text = span("About", style = "font-size: 20px"),
tabName = "about",
icon = icon("info-circle")
)
)
)
####################
# #
# Exercise 8 #
# #
####################
sidebar <- dashboardSidebar(
width = "300px",
sidebarMenu(
menuItem(
text = span("Data", style = "font-size: 20px"),
tabName = "data",
icon = icon("database"),
badgeLabel = "New",
badgeColor = "yellow"
),
menuItem(
text = span("About", style = "font-size: 20px"),
tabName = "about",
icon = icon("info-circle"),
menuSubItem(text = "Licenses", tabName = "licenses"),
menuSubItem(text = "Contact Us", tabName = "contact_us")
)
)
)
####################
# #
# Exercise 9 #
# #
####################
sidebar <- dashboardSidebar(
width = "300px",
sidebarMenu(
sidebarSearchForm(
textId = "search_text",
buttonId = "search_button",
label = "What are you looking for?"
),
menuItem(
text = span("Data", style = "font-size: 20px"),
tabName = "data",
icon = icon("database"),
badgeLabel = "New",
badgeColor = "yellow"
),
menuItem(
text = span("About", style = "font-size: 20px"),
tabName = "about",
icon = icon("info-circle"),
menuSubItem(text = "Licenses", tabName = "licenses"),
menuSubItem(text = "Contact Us", tabName = "contact_us")
)
)
)
####################
# #
# Exercise 10 #
# #
####################
sidebar <- dashboardSidebar(
width = "300px",
sidebarMenu(
sidebarSearchForm(
textId = "search_text",
buttonId = "search_button",
label = "What are you looking for?"
),
selectInput(
inputId = "plant",
label = "Select Plant",
choices = unique(CO2$Plant)
),
menuItem(
text = span("Data", style = "font-size: 20px"),
tabName = "data",
icon = icon("database"),
badgeLabel = "New",
badgeColor = "yellow"
),
menuItem(
text = span("About", style = "font-size: 20px"),
tabName = "about",
icon = icon("info-circle"),
menuSubItem(text = "Licenses", tabName = "licenses"),
menuSubItem(text = "Contact Us", tabName = "contact_us")
)
)
)
################################
# #
# All Exercises Combined #
# #
################################
header <- dashboardHeader(
# exercise 1
title = span(
"Practicing shinydashboard",
style = "font-family: Tahoma; font-weight: bold"
),
# exercise 2
titleWidth = "300px"
)
sidebar <- dashboardSidebar(
# exercise 2
width = "300px",
sidebarMenu(
# exercise 9
sidebarSearchForm(
textId = "search_text",
buttonId = "search_button",
label = "What are you looking for?"
),
# exercise 10
selectInput(
inputId = "plant",
label = "Select Plant",
choices = unique(CO2$Plant)
),
# exercise 5
menuItem(
text = span("Data", style = "font-size: 20px"),
tabName = "data",
icon = icon("database"), # exercise 6
badgeLabel = "New", # exercise 7
badgeColor = "yellow" # exercise 7
),
# exercise 5
menuItem(
text = span("About", style = "font-size: 20px"),
tabName = "about",
icon = icon("info-circle"), # exercise 6
menuSubItem(text = "Licenses", tabName = "licenses"), # exercise 8
menuSubItem(text = "Contact Us", tabName = "contact_us") # exercise 8
)
)
)
body <- dashboardBody()
ui <- dashboardPage(
# exercise 3
skin = "black",
# exercise 4
title = "R-Exercises",
header = header,
sidebar = sidebar,
body = body
)
server <- function(input, output, session) {}
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment