错误:R的Shiny应用程序中的“数学函数中的非数值参数”

用户名

假设我有以下功能

abc<-function(obs, dist, dir)
{
n=obs
if(dist=='normal1')
x<-rnorm(n, mean=0, sd=1)

if(dist=='normal2')
x<-rnorm(n, mean=0, sd=2)

if(dir=='right')
y<-qbinom(1-0.05, n, 0.5, lower.tail=TRUE, log.p=FALSE)
if(dir=='left')
y<-qbinom(0.05, n, 0.5, lower.tail=TRUE, log.p=FALSE)
if(dir=='both')
y<-qbinom(c(0.05/2, 1-(0.05/2)), n, 0.5, lower.tail=TRUE, log.p=FALSE)


P<-data.frame("mean"=mean(x), "observation"=n, "direction"=y)
return(P)
}

我在markdown文档中使用此功能来使用光泽制作交互式数据框。我使用以下代码:


library(shiny)
shinyApp(
ui <- fluidPage(
  titlePanel("comparison of means"),
  fluidRow( 
    column(3,
           radioButtons("dist", h3("Distribution"),
                        choices = c("normal1" , "normal2"
                                      ))),   

  column(4,
           radioButtons("dir", h4("Direction"),
                        choices = c("left" , "right", "both"
                                      ))), 

  column(5,
         radioButtons("obs", h5("observation"),
                      choices = c(1,2,3,4,5 
                      )))


  ),  
  tableOutput("table")

),

server<-function(input, output){
output$table<-renderTable( {abc(input$obs, input$dist, input$dir)})


}
)

当我运行应用程序时,出现以下错误:

Warning: Error in qbinom: Non-numeric argument to mathematical function

dir在计算qbinom函数,字符参数可能会引起一些问题有人可以告诉我我在哪里做错吗?

布雷泰夫

radioButtons提供一个字符值。您必须更换input$obsas.numeric(input$obs)renderTable

numericInput可能比radioButtons观测组件更适合as.numeric如果使用不需要numericInput)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

错误:R中数学函数的非数字参数

如何解决数值积分中的“非数值参数..”错误?

函数中的r值参数

将函数解析添加到具有非数值参数的简单pyparsing中

es6 箭头函数,未在 React 应用程序中获取参数值

round(n)中的错误:数学函数的非数字参数

y(sort(x),...)中的错误:数学函数的非数字参数

abs(x)中的错误:数学函数R lang的非数字参数

用户单击按钮时如何在VBS用户定义的函数中传递字符串值参数(HTA应用程序)

将附加参数传递给 R Shiny 应用程序中的 moduleServer:访问 updateTabsetPanel 的父环境

` 在 R 中,“错误:尝试应用非函数”

在Shiny应用程序中定义sliderInput函数

在Shiny Web应用程序中显示错误而不是绘图

r Shiny.io错误中的小叶闪亮应用程序

在angular 2应用程序中调用非角度函数

在R Shiny应用程序中返回HTTP状态代码

R Shiny 应用程序中的外部过滤器

r Shiny应用程序中的URL缩短器

VirtualBox 环境中的 R Shiny 应用程序

无法在R Shiny应用程序中显示模式警报

带R的Shiny应用程序中的相关输入

在R Shiny应用程序中接受HTTP请求

在 R Shiny 应用程序中嵌入特定推文

在R Shiny应用程序中并排生成UI元素

在R Shiny应用程序中访问Javascript变量

使用传递给闪亮应用程序的参数将R Shiny应用程序另存为函数

localTodos应用程序的回调函数中缺少参数

Azure函数:应用程序冻结-错误消息中的“ UnableToLoadExpressionAssembly”

funtrans(sort(unique(model_frame [[y]])))中的错误:数学函数的非数字参数