Skip to content

Commit 82e02ef

Browse files
committed
Export functionality
1 parent bf87217 commit 82e02ef

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

Block_Randomization/Block_randomization_web_app.R

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ ui <- fluidPage(
3636
min = 1,
3737
max = 4,
3838
value = 2
39-
)
39+
),
40+
downloadButton('downloadData', 'Download')
4041
),
4142

4243
# Show result table
4344
mainPanel(tableOutput("filetable"))
45+
4446
))
4547

4648

@@ -53,10 +55,22 @@ server <- function(input, output)
5355
block.random(n = input$trials, c(block = input$blocks, drug = input$cases))
5456
output <- data.frame(condition)
5557
colnames(output) <- c("Block", "to_be_discarded", "Case")
56-
output[,-2]
58+
data <- output[,-2]
5759
})
60+
data <- mtcars
61+
output$table <- renderTable({
62+
datasetInput()
63+
})
64+
output$downloadData <- downloadHandler(
65+
filename = function() {
66+
paste("trials", '.txt', sep='')},
67+
content = function (file){
68+
write.csv(data,file)
69+
}
70+
)
5871
}
5972

6073
# Run application ---------------------------------------------------------
6174

6275
shinyApp(ui = ui, server = server)
76+

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
# Block_randomization
1+
# Block_randomization
2+
3+
Repository contains R scripts and Shiny web app that can be used to generate block randomized trials for experiments.
4+
5+
#### Default parameters -
6+
7+
* N = 150
8+
* Blocks = 3
9+
* Cases = 2
10+
11+
Total block length = (Block * Cases)
12+
Example: Total block length = 3 * 2 = 6
13+
14+
#### Web app features
15+
16+
* Select input parameters from slider/textbox
17+
* Export table in csv format
18+

block_randomization.r

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,12 @@
22

33
library(psych)
44

5-
<<<<<<< HEAD
6-
=======
7-
8-
>>>>>>> 2466edf175a3c69eabc548936feda00f5b96a19e
95
# Generate N number of trials ---------------------------------------------
106

117
n <- 150
128
not_useful <- 3
139
cases <- 2
1410

15-
<<<<<<< HEAD
16-
=======
17-
18-
>>>>>>> 2466edf175a3c69eabc548936feda00f5b96a19e
1911
# Generate randomized trials for N = 150 ----------------------------------
2012

2113
trials <- block.random(n,c(not_useful, cases))

0 commit comments

Comments
 (0)