/
ui.R
88 lines (77 loc) · 2.6 KB
/
ui.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 2016 election analysis - Shiny App UI script
library(shinydashboard)
# Title header
header <- dashboardHeader(
title = '2016 Presidential Election',
titleWidth = 300
)
# Sidebar with data sources
sidebar <- dashboardSidebar(
width = 300,
div(
style='margin: 12px',
p('State-by-state results from the 2016 US presidential election, with information about state populations, electors, and campaign expenditures.'),
p('Find the source code and cleaned data on ',
a(href='https://github.com/kshaffer/election2016', 'GitHub.', style='text-decoration: underline')
),
p('Data sources:'),
tags$ul(
tags$li(a(href='https://en.wikipedia.org/wiki/United_States_presidential_election,_2016',
'Election results',
style='text-decoration: underline',
target='_blank')),
tags$li(a(href='https://en.wikipedia.org/wiki/List_of_U.S._states_and_territories_by_population',
'State populations',
style='text-decoration: underline',
target='_blank'
)),
tags$li(a(href='https://en.wikipedia.org/wiki/Electoral_College_(United_States)',
'Electoral college',
style='text-decoration: underline',
target='_blank'
)),
tags$li(a(href='http://www.fec.gov/disclosurep/pnational.do',
'Expenditures',
style='text-decoration: underline',
target='_blank'
))
)
)
)
# Main dashboard layout
body <- dashboardBody(
# Title header
fluidRow(
h1(strong('2016 US presidential election'), align='center'),
br()
),
fluidRow(
column(8,
# New registrations over time - plot/table tabs selected by user
plotOutput('state_by_state_plot')
),
column(4,
# Menus for user-selected time frame and status filters
wellPanel(
selectInput('parameter',
label = 'Data parameter',
choices = c('Population',
'Electors',
'Votes',
'Voter turnout',
'Electors per citizen',
'Electors per voter',
'Margin of victory',
'Trump & Clinton Expenditures'),
selected = 'Population')
)
)
)#,
# fluidRow(
# dataTableOutput('state_by_state_table')
# )
)
# Build the dashboard page
shinyUI(
dashboardPage(header, sidebar, body)
)