library(shiny)
library(shinydashboard)
library(rwunderground)
library(measurements)
set_api_key("353685eb1f5194e3")
header <- dashboardHeader(title = 'Athens GA weather watch')
sidebar <- dashboardSidebar()
loc <- set_location(airport_code = 'AHN')
weather <- conditions(loc)
weather$tempC <- round(conv_unit(weather$temp,'F','C'),1)
boxTemperatureF <- box(title='Fahrenheit', weather$temp)
boxTemperatureC <- box(title='Celsius',weather$tempC)
row1 <- fluidRow(boxTemperatureF, boxTemperatureC)
body <- dashboardBody(row1)
ui <- dashboardPage(header,sidebar,body)
server <- function(input, output) {}
shinyApp(ui, server)
library(shiny)
library(shinydashboard)
library(rwunderground)
header <- dashboardHeader(title = 'Current weather')
sidebar <- dashboardSidebar()
boxCity <- box(selectInput('code', 'City:', choices = c('Atlanta' = 'ATL', 'Fairbanks' = 'FAI', 'New York' = 'JFK', 'Phoenix' = 'PHX', 'San Francisco' = 'SFO'), selected = 'ATL'))
#boxCondition <- box(title = 'Current conditions: ', textOutput('condition'), background = 'blue')ndition <-
boxTime <- box(textOutput('time'))
row1 <- fluidRow(boxCity)
row2 <- fluidRow(valueBoxOutput("vboxF"), valueBoxOutput("vboxC"))
body <- dashboardBody(row1,row2)
ui <- dashboardPage(header,sidebar,body)
server <- function(input, output) {
output$vboxF <- renderValueBox({
t <-
as.numeric(conditions(set_location(airport_code = input$code))$temp)
if (t > 86)
{
valueBox(t, width = 3, subtitle = 'F', color = 'red')
}
else if (t < 50)
{
valueBox(t, width = 3, subtitle = 'F', color = 'blue')
}
else {
valueBox(t, width = 3, subtitle = 'F', color = 'yellow')
}
})
output$vboxC <- renderValueBox({
t <-
as.numeric( output$vboxC <- renderValueBox({
t <-
as.numeric(round(conv_unit(conditions(set_location(airport_code = input$code))$temp,"F","C"),1))
if (t > 30)
{
valueBox(t, width = 3, subtitle = 'C', color = 'red')
}
else if (t < 10)
{
valueBox(t, width = 3, subtitle = 'C', color = 'blue')
}
else {
valueBox(t, width = 3, subtitle = 'C', color = 'yellow')
}
})
)
if (t > 30)
{
valueBox(t, width = 3, subtitle = 'C', color = 'red')
}
else if (t < 10)
{
valueBox(t, width = 3, subtitle = 'C', color = 'blue')
}
else {
valueBox(t, width = 3, subtitle = 'C', color = 'yellow')
}
})
}
shinyApp(ui, server)
This page is part of the promotional and support material for Data Management (open edition) by Richard T. Watson |