【问题标题】:$ operator is invalid for atomic vectors in shiny R$ 运算符对闪亮 R 中的原子向量无效
【发布时间】:2021-08-23 05:14:35
【问题描述】:

psych 包中有一个名为“alpha”的函数,它给出了各种统计数据。我想要输出中的特定列,所以我使用代码。此代码在控制台中完美运行,但当我尝试在闪亮中使用它时它不起作用。

library(shiny)
library(mirt)#This contains a dataset called deAyala
library(psych)#This has the alpha() function

server<- shinyServer(
    
    function(input, output) {
        
        output$data <- renderUI({
            
            alpha(deAyala,warnings=FALSE)$item.stats$raw.r #Warning disables the warnings 
            
            
            
        })
        
        
    }
)


ui<- shinyUI(fluidPage(
    titlePanel(title = h4("Output", align="center")),
    sidebarLayout(
        sidebarPanel(
        ),
        
        mainPanel(
            uiOutput("data"),
            
        )
        
    )
    
))


shinyApp(ui = ui, server = server)

【问题讨论】:

    标签: r shiny shinydashboard shiny-server shinyapps


    【解决方案1】:

    您可以使用renderTablerenderText 代替renderUI 来显示输出。

    library(shiny)
    
    server<- shinyServer(
      function(input, output) {
        output$data <- renderTable({
          alpha(deAyala,warnings=FALSE)$item.stats$raw.r
        })
      }
    )
    
    ui<- shinyUI(fluidPage(
      titlePanel(title = h4("Output", align="center")),
      sidebarLayout(
        sidebarPanel(
        ),
        mainPanel(
          tableOutput("data"),
        )
      )
    ))
    
    shinyApp(ui = ui, server = server)
    

    【讨论】:

    • 我仍然有工作的唯一原因是因为你罗纳克。谢谢
    • 我收到第一笔钱后马上给你买杯咖啡
    • 不用担心。很高兴我的回答对您有所帮助。
    • 你能帮忙解决这个问题吗? stackoverflow.com/questions/67927608/…
    猜你喜欢
    • 2019-04-29
    • 1970-01-01
    • 1970-01-01
    • 2021-08-20
    • 2014-05-15
    • 2013-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多