2
library(shiny)
ui <- fluidPage(
titlePanel("Funcao Poder"),
sidebarLayout(
sidebarPanel(
sliderInput("n1",
"Tamanho da amostra:",
min = 1,
max = 50,
value = 30),
sliderInput("n2",
"Tamanho da amostra:",
min = 1,
max = 50,
value = 30),
sliderInput("n3",
"Tamanho da amostra:",
min = 1,
max = 50,
value = 30),
sliderInput("n4",
"Tamanho da amostra:",
min = 1,
max = 50,
value = 30)
),
mainPanel(
plotOutput("p1")
)
)
)
server <- function(input, output) {
output$p1 <- renderPlot({
poder.media = function(n,mu){
k = qnorm(1-0.05,50,sqrt(25/n))
prob = 1 - pnorm(k, mu, sqrt(25/n))
return(prob)
}
n <- input$n1
curve(poder.media(n,x),40,60,xlab=expression(mu),ylab = "Poder",add=TRUE,col="red")
nn <- input$n2
curve(poder.media(nn,x),40,60,xlab=expression(mu),ylab = "Poder",add=TRUE,col="blue")
nnn <- input$n3
curve(poder.media(nnn,x),40,60,xlab=expression(mu),ylab = "Poder",add=TRUE,col="green")
nnnn <- input$n4
curve(poder.media(nnnn,x),40,60,xlab=expression(mu),ylab = "Poder",add=TRUE,col="yellow")
})
}
shinyApp(ui = ui, server = server)
I would like to generate a q application for each n
changed in the input is generated a curve with the function placed in the server (the function is in the right place?).
Thank you so much for your help
– Gabriel Mizuno