The idea of the App is to do two different things:
- Sum two numbers definied by a slider
- Throw a dice and generate a histogram with the plots
18/4/2021
The idea of the App is to do two different things:
The calculation of the histogram is done my runing runif and ploting the results. Here is a example
data <- runif(50, 1, 6) hist(data)
dashboardBody(
fluidRow(
br(),
h1("The Week 4 project")
),
fluidRow(
h3("You can select two buttons at the panel and will get as a result the sum of these two numbers"),
valueBoxOutput("Result")
),
fluidRow(
h3("Here you can throw a dice and the histogram will be showing the results"),
valueBoxOutput("DiceRes"),
plotOutput("histogram")
)
)
rv <- reactiveValues(diceRoll = NULL, diceRolls = 0)
observeEvent(input$Dice, {
rv$diceRoll <- round(runif(1,1,6))
if (rv$diceRolls[1]== 0) {rv$diceRolls <- rv$diceRoll}
else {rv$diceRolls <- c(rv$diceRolls, rv$diceRoll)}
})
output$DiceRes <- renderValueBox({
valueBox(
value = rv$diceRoll,
subtitle = "Dice Result",
color = "yellow"
)
})
output$histogram <- renderPlot(hist(rv$diceRolls))