【发布时间】:2018-07-14 03:39:20
【问题描述】:
我试图让 Shiny (R) 在第二个fluidRow 语句定义的第二行中显示最低温度(用于测试的随机数据),但没有运气。这不适用于生产脚本。我只是想学习Shiny。我有一种感觉,我没有在 ui 和服务器组件之间正确调用东西,但我不知道是什么。任何帮助将不胜感激。
另外,我想知道是否有人对我使用 Shiny 应用程序获取可能有数百万行的天气数据有任何想法。这会很慢,甚至是不可能的吗?谢谢。
library(shiny)
library(ggplot2)
library(lubridate)
options(shiny.maxRequestSize = 100*1024^2)
# Define UI for data upload app ----
ui <- fluidPage(
# App title ----
titlePanel("My First Shiny App"),
fluidRow(
column(width = 3,
# Input: Select a file ----
fileInput("file1", "Choose CSV File",
multiple = FALSE,
accept = c("text/csv",".csv"))
)
),
fluidRow(
column(width = 3,
textOutput("info")
)
)
)
# Define server logic to read selected file ----
server <- function(input, output) {
output$contents <- renderText({
req(input$file1)
df <- read.csv(input$file1$datapath, header = TRUE)
output$info <- renderText({
return(min(df$Temp))
})
})
}
# Create Shiny app ----
shinyApp(ui, server)
Date,Temp,Precipitation,Station
2018-01-01 00:05:00,-1,0,ATRS2
2018-01-02 00:10:00,-10,0,BSNS2
2018-01-03 00:15:00,-2,0,BKMS2
2018-01-04 00:20:00,-1,0,ATRS2
2018-01-05 00:25:00,-9,0,BSNS2
2018-01-06 00:30:00,-10,0,BKMS2
2018-01-07 00:35:00,-6,0,ATRS2
2018-01-08 00:40:00,-10,0,BSNS2
2018-01-09 00:45:00,-5,0,BKMS2
2018-01-10 00:50:00,-2,0,ATRS2
2018-01-11 00:55:00,-6,0.254,BSNS2
2018-01-12 01:00:00,-1,0.254,BKMS2
2018-01-13 01:05:00,-7,0,ATRS2
2018-01-14 01:10:00,-3,0,BSNS2
2018-01-15 01:15:00,-10,0,BKMS2
2018-01-16 01:20:00,-10,0,ATRS2
2018-01-17 01:25:00,-2,0,BSNS2
2018-01-18 01:30:00,-8,0,BKMS2
2018-01-19 01:35:00,-9,0,ATRS2
2018-01-20 01:40:00,-4,0,BSNS2
2018-01-21 01:45:00,-8,0,BKMS2
2018-01-22 01:50:00,-3,0,ATRS2
2018-01-23 01:55:00,-2,0,BSNS2
2018-01-24 02:00:00,-3,0,BKMS2
【问题讨论】:
标签: r shiny shiny-server