r - 我创建了一个闪亮的应用程序来显示所选公司的股票价格图。如何以表格形式显示价格?
问题描述
我创建了一个闪亮的应用程序来显示所选公司的股价图。我也想以表格形式显示价格,但我无法做到。在尝试错误消息状态时 cannot coerce class ‘c("reactiveExpr", "reactive")’ to a data.frame
。代码如下:
# Load packages ----
library(shiny)
library(quantmod)
#edited code.this可以直接运行
# User interface ----
ui <- fluidPage(
titlePanel("stockVis"),
sidebarLayout(
sidebarPanel(
helpText("Select a stock to examine.
Information will be collected from Yahoo finance."),
textInput("symb", "Symbol", "SPY"),
dateRangeInput("dates",
"Date range",
start = "2013-01-01",
end = as.character(Sys.Date())),
br(),
br(),
checkboxInput("log", "Plot y axis on log scale",
value = FALSE)
#checkboxInput("adjust",
#"Adjust prices for inflation", value = FALSE)
),
mainPanel(plotOutput("plot"), tableOutput("view")))
)
# Server logic
server <- function(input, output) {
dataInput <- reactive({
getSymbols(input$symb, src = "yahoo",
from = input$dates[1],
to = input$dates[2],
auto.assign = FALSE)
})
output$plot <- renderPlot({
chartSeries(dataInput(), theme = chartTheme("white"),
type = "line", log.scale = input$log, TA = NULL)
})
output$view <- renderTable({(dataInput )
}, include.rownames = TRUE)
}
# Run the app
shinyApp(ui, server)
解决方案
As the error says its a reactive
function so you have to use it as such: dataInput()
and not dataInput
output$view <- renderTable({
dataInput()
}, include.rownames = TRUE)
推荐阅读
- ios - 如何使用 IBInspectable 数据进行自定义 segue
- python - 基于另一个(不规则)时间序列的下采样时间序列,熊猫
- c - 线程双释放中的卷曲请求
- python - 在 TensorFlow 中训练后变量未更新,即使使用统一随机启动进行简单的逻辑回归也是如此
- c# - 我想更新一个 num 参数并将其汇总到我的数据库中...遇到问题... Gridview
- ios - 如何在 iOS 中找到生成的 Link Map 文件
- ionic-framework - Ionic 照片库无法在 iOS 设备中加载
- marklogic - 同一路径的多个模板 (MarkLogic)
- java - 'compareTo' 比较用例
- google-apps-script - 从多个时区的电子表格数据创建日历事件时间