Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
iguir2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pet-estatistica
iguir2
Commits
fbe7fd9a
Commit
fbe7fd9a
authored
9 years ago
by
Eduardo E. R. Junior
Browse files
Options
Downloads
Patches
Plain Diff
Adiciona botão de recomeçar à aplicação
parent
4150ec06
Branches
Branches containing commit
No related tags found
1 merge request
!4
Issue#2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
shiny/testHipFlipCoin/server.R
+38
-34
38 additions, 34 deletions
shiny/testHipFlipCoin/server.R
shiny/testHipFlipCoin/ui.R
+6
-1
6 additions, 1 deletion
shiny/testHipFlipCoin/ui.R
with
44 additions
and
35 deletions
shiny/testHipFlipCoin/server.R
+
38
−
34
View file @
fbe7fd9a
...
...
@@ -13,7 +13,6 @@ moeda <- function(n){
}
## Vetor vazio.
x
<-
integer
()
N
<-
1000
shinyServer
(
...
...
@@ -22,31 +21,33 @@ shinyServer(
output
$
header
<-
renderPrint
({
template
(
"TEMA"
)
})
# cara <- eventReactive(input$goCara, {
# x <<- c(x, 1L)
# })
# coro <- eventReactive(input$goCoro, {
# x <<- c(x, 0L)
# })
# output$nlanc <- renderText({
# coro(); cara()
# return(length(x))
# })
cara
<-
reactive
({
input
$
goCara
x
<<-
c
(
x
,
1L
)
## Cria valores para reagirem à estímulos dos buttons
v
<-
reactiveValues
(
x
=
integer
())
## Responde a estímulos no `input$goCara`.
observeEvent
(
input
$
goCara
,
{
v
$
x
<-
c
(
v
$
x
,
1L
)
})
coro
<-
reactive
({
input
$
goCoro
x
<<-
c
(
x
,
0L
)
## Responde a estímulos no `input$goCoro`.
observeEvent
(
input
$
goCoro
,
{
v
$
x
<-
c
(
v
$
x
,
0L
)
})
## Responde a estímulos no `input$goCoro`.
observeEvent
(
input
$
clear
,
{
v
$
x
<-
integer
()
})
## x começa com dois elementos. Descontá-los.
output
$
nlanc
<-
renderText
({
coro
();
cara
()
return
(
length
(
x
)
-2
)
return
(
length
(
v
$
x
))
})
process
<-
eventReactive
(
input
$
goProcess
,
{
x
<-
x
[
-
c
(
1
:
2
)]
with
(
reactiveValuesToList
(
v
),
{
x
<-
x
## Número de lançamentos.
n
<-
length
(
x
)
## Número de caras.
...
...
@@ -58,16 +59,19 @@ shinyServer(
## P-valor bilateral empírico.
p
<-
min
(
c
(
2
*
min
(
c
(
sum
(
r
<=
o
),
sum
(
r
>=
o
)))
/
N
,
1
))
## Lista com todos os elementos.
return
(
list
(
n
=
n
,
k
=
k
,
o
=
o
,
r
=
r
,
p
=
p
,
x
=
x
))
list
(
n
=
n
,
k
=
k
,
o
=
o
,
r
=
r
,
p
=
p
,
x
=
x
)
})
})
output
$
seqx
<-
renderText
({
s
<-
paste0
(
process
()
$
x
,
collapse
=
""
)
return
(
s
)
})
output
$
hist
<-
renderPlot
({
with
(
process
(),{
if
(
n
<=
9
){
stop
(
"Pro favor, lance no mínimo
30
vezes."
)
if
(
n
<=
15
){
stop
(
"Pro favor, lance no mínimo
15
vezes."
)
}
par
(
mar
=
c
(
5
,
4
,
3
,
2
),
family
=
"Palatino"
)
layout
(
matrix
(
c
(
1
,
2
,
1
,
3
),
2
,
2
))
...
...
This diff is collapsed.
Click to expand it.
shiny/testHipFlipCoin/ui.R
+
6
−
1
View file @
fbe7fd9a
...
...
@@ -17,6 +17,7 @@ shinyUI(
h4
(
"Você consegue imitar uma moeda?"
),
p
(
txt
),
hr
(),
sidebarPanel
(
helpText
(
"Clique nos botões para declarar cara ou coroa."
),
actionButton
(
"goCara"
,
"Cara"
),
...
...
@@ -24,10 +25,14 @@ shinyUI(
h6
(
"Número de lançamentos feitos:"
),
verbatimTextOutput
(
"nlanc"
),
actionButton
(
"goProcess"
,
"Aplicar teste de hipótese!"
),
actionButton
(
"clear"
,
"Recomeçar"
),
h6
(
"Sequência das faces observadas (1=cara, 0=coroa):"
),
verbatimTextOutput
(
"seqx"
),
checkboxInput
(
"teorico"
,
"Valores teóricos: Binomial(n-1, p=0.5)"
)
checkboxInput
(
"teorico"
,
"Valores teóricos: Binomial(n-1, p=0.5)"
)
),
mainPanel
(
plotOutput
(
"hist"
,
width
=
500
,
height
=
500
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment