Suma V R
Suma V R

Reputation: 11

I am new to shiny and I am trying to put a simple App for repeatable

I get the following error.

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

With...

# 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()
  )
))

and...

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

Upvotes: 0

Views: 220

Answers (1)

Stanislav
Stanislav

Reputation: 2677

I image you want a simple example of shiny with random values. Here is the UI and Server code for it (three different captions for you):

# 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)
    } )
  }
)

Kind Regards,

Upvotes: 1

Related Questions