我是新来的闪亮,我试图把一个简单的应用程序重复

时间:2015-02-07 06:54:18

标签: r shiny shiny-server

我收到以下错误。

Listening on http://127.0.0.1:6814
Error in as.character(x) : 
  cannot coerce type 'closure' to vector of type 'character'

使用...

# ui.R -------------
library(shiny)
shinyUI(fluidPage(
   titlePanel("Old Faithful Geyser Data"),
  sidebarLayout(sidebarPanel(
      rnormA <- repeatable(rnorm),
      rnormB <- repeatable(rnorm),
      rnormA(3), # [1] 1.8285879 -0.7468041 -0.4639111
      rnormA(3), # [1] 1.8285879 -0.7468041 -0.4639111
      rnormA(5), # [1] 1.8285879 -0.7468041 -0.4639111 -1.6510126 -1.4686924
      rnormB(5) # [1] -0.7946034 0
          ),
       mainPanel()
  )
))

和...

# server.R --------------
library(shiny)
shinyServer(function(input, output){repeatable(rngfunc, seed = runif(1, 0, .Machine$integer.max))
})

1 个答案:

答案 0 :(得分:0)

我想要一个简单的随机值闪亮的例子。 以下是它的UI和服务器代码(三种不同的标题):

# ui.R -------------
library(shiny)
shinyUI(fluidPage(
  titlePanel("Side Panel"),
  sidebarLayout(sidebarPanel(
    h3(textOutput("captionA")),
    h3(textOutput("captionB"))
  ),
  mainPanel(titlePanel("Main Panel"),
            h3(textOutput("captionAB"))
  )
  )
))

-

# server.R --------------
library(shiny)

shinyServer(
  function(input, output){

    output$captionA <- renderText({ 
      repeatable(rngfunc, seed = runif(1, 0, .Machine$integer.max))
      rnormA <- repeatable(rnorm)
      rnormA(3)
    } )

    output$captionB <- renderText({ 
      repeatable(rngfunc, seed = runif(1, 0, .Machine$integer.max))
      rnormB <- repeatable(rnorm)
      rnormB(3)
    } )

    output$captionAB <- renderText({ 
      repeatable(rngfunc, seed = runif(1, 0, .Machine$integer.max))
      rnormA <- repeatable(rnorm)
      rnormB <- repeatable(rnorm)
      a<-rnormA(3)
      b<-rnormB(5)
      round(c(a,b),2)
    } )
  }
)

亲切的问候,