【问题标题】:R - Shiny can not find "container"R - Shiny找不到“容器”
【发布时间】:2017-10-15 13:51:13
【问题描述】:

我正在尝试创建一个基本的财务闪亮应用程序,该应用程序将公司的股票代码作为输入,并利用 quantmod 包中的各种功能来返回某些信息(损益表、现金流等)。我遇到了错误,上面写着“错误:找不到函数”容器。”我知道大多数时候闪亮的错误是由于某处没有右括号,但情况似乎并非如此,我在玩之前没有遇到过这个错误。任何帮助表示赞赏。

ui.R

library(shiny)
shinyUI(
      fluidPage(
            titlePanel("Should You Invest"),
            sidebarLayout(
                  sidebarPanel(h3("How It Works"),
                        "You input the ticker symbol of a company, and this app returns the
                        Net Current Asset Value per Share, otherwise known as Grahams Rule", 
                        textInput("ticker",
                                  "Company Ticker",
                                  placeholder = "AAPL"),
                        submitButton("Submit"),
                        textOutput("last_price",
                                   "Last Traded Price"),
                        textOutput("NCAVPS",
                                   "Net Current Asset Value per Share")
                  ),
                  mainPanel(
                        tabsetPanel(type = "pills",
                                    tabPanel("Annual",
                                             tabsetPanel(type = "tabs",
                                                         tabPanel("Balance Sheet",
                                                                  textOutput("annual_bs")),
                                                         tabPanel("Cash Flow",
                                                                  textOutput("annual_cf")),
                                                         tabPanel("Income Statement",
                                                                  textOutput("annual_is"))
                                                      )
                                    ),
                                    tabPanel("Quarter",
                                             tabsetPanel(type = "tabs",
                                                         tabPanel("Balance Sheet",
                                                                  textOutput("quarter_bs")),
                                                         tabPanel("Cash Flow",
                                                                  textOutput("quarter_cf")),
                                                         tabPanel("Income Statement",
                                                                  textOutput("quarter_is"))
                                                      )
                                    )         
                        )
                  )
            )
      )
)

服务器.R

library(shiny)
shinyServer(function(input, output) {
      library(quantmod)
      change_ticker <- reactive(function() {
            ticker <- input$ticker
            adj_ticker <- getFin(ticker)
            financial <- get(adj_ticker)
            financial
      })      
      output$last_price <- renderTable(
            getQuote(ticker)
      )
      output$annual_bs <- renderText(
            viewFinancials(financial, type = "BS", period = "A")
      )
      output$annual_cf <- renderText(
            viewFinancials(financial, type = "CF", period = "A")
      )
      output$annual_is <- renderText(
            viewFinancials(financial, type = "IS", period = "A")
      )
      output$quarter_bs <- renderText(
            viewFinancials(financial, type = "BS", period = "Q")
      )
      output$quarter_cf <- renderText(
            viewFinancials(financial, type = "CF", period = "Q")
      )
      output$quarter_is <- renderText(
            viewFinancials(financial, type = "IS", period = "Q")
      )
})

【问题讨论】:

    标签: r shiny quantmod financial


    【解决方案1】:

    textOutputs 没有标签,所以这不起作用:

    textOutput("last_price",
               "Last Traded Price"),
    textOutput("NCAVPS",
               "Net Current Asset Value per Share")
    

    第二个参数是container,一个生成 HTML 容器的函数。标签必须是单独的,例如

    div(
      tags$b("Last Traded Price"),
      textOutput("last_price")
    )
    

    【讨论】:

      猜你喜欢
      • 2019-04-05
      • 2018-09-14
      • 1970-01-01
      • 1970-01-01
      • 2017-12-29
      • 1970-01-01
      • 2018-10-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多