Skip to content

Commit

Permalink
Several changes for #46, #47 and #55
Browse files Browse the repository at this point in the history
- inverted the order of dependent and independent columns for ancova1
- changed the randomization columns for ancova1 and 2 to be the
  categorial variable
- added an error printing on the Rsampling::Rsampling catch
- Locks down the choice of rand types for some statistics
  • Loading branch information
andrechalom committed Jun 9, 2016
1 parent 0e2e20a commit 73c2d5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lang.csv
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ powered by ;powered by ;implementado em
Mean of row 3:;Mean of row 3:;Média da linha 3:
Statistic:;Statistic:;Estatística:
Numerical variable column;Numerical variable column;Coluna de variável numérica
Here is where we do the randomization!;Here is where we do the randomization!;Aqui é onde nós fazemos a aleatorização!
Here is where we do the randomization!;Here is where we do the randomization! Note that for many statistics there is only one choice of randomization type, but for others you need to chose carefully.;Aqui é onde nós fazemos a aleatorização! Note que várias estatísticas só admitem um tipo de aleatorização, mas para as demais a escolha precisa ser cuidadosamente pensada.
Below you see the result of this function applied to the original data:;Below you see the result of this function applied to the original data:;Abaixo, veja o resultado desta função aplicada aos dados originais:
Randomization type:;Randomization type:;Tipo de aleatorização
In normal resampling the data is randomized over all cells of the selected columns. If you do not check the 'With replacement' box below the data is permuted over the cells. Otherwise the data from any cell are sampled with replacement and attributed to any other cell.;In normal resampling the data is randomized over all cells of the selected columns. If you do not check the 'With replacement' box below the data is permuted over the cells. Otherwise the data from any cell are sampled with replacement and attributed to any other cell.; Na permutação normal os dados são amostrados com reposição e atribuídos a qualquer outra célula. Se você não marcar a caixa 'com reposição' abaixo os dados são permutados por todas as células. De outro modo os dados de qualquer célula são amostrados com substituição e e atribuídos a qualquer outra célula
Expand Down
19 changes: 16 additions & 3 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ shinyServer(function(input, output, session) {
###########################################
### INTERNAL OBJECTS AND INPUT HANDLING ###
###########################################
optionsRand <- c("Normal", "Within rows", "Within columns", "Rows as units", "Columns as units")
names(optionsRand) <- tr(optionsRand)
#### Selection of prebuilt statistic functions
smean <- function(dataframe){
mean(dataframe[,as.numeric(input$m1)])
Expand Down Expand Up @@ -44,7 +46,7 @@ shinyServer(function(input, output, session) {
ancova1 <- function(dataframe){
# Difference between slopes of regressions fitted to two groups
slope = function(x) coef(lm(x[,2]~x[,1]))[2]
props = by(dataframe[,as.numeric(c(input$m1,input$m2))], dataframe[,as.numeric(input$m3)], slope)
props = by(dataframe[,as.numeric(c(input$m2,input$m1))], dataframe[,as.numeric(input$m3)], slope)
props[1] - props[length(props)]
}
ancova2 <- function(dataframe){
Expand All @@ -67,8 +69,11 @@ shinyServer(function(input, output, session) {
if(input$stat %in% c("meandif","Fstatistic", "slope", "intercept", "corr"))
return(as.numeric(input$m2))
# both columns are randomized
if(input$stat %in% c("meandifc", "ancova1", "ancova2"))
if(input$stat %in% c("meandifc"))
return(c(as.numeric(input$m1), as.numeric(input$m2)))
# the categorical variable is randomized
if(input$stat %in% c("ancova1", "ancova2"))
return(as.numeric(input$m3))
# all columns should be used
if(input$stat %in% c("scol", "srow"))
return(1:ncol(data()))
Expand Down Expand Up @@ -151,7 +156,7 @@ shinyServer(function(input, output, session) {
ntrials = isolate(input$ntrials),
replace=isolate(input$replace),
progress = pupdate),
error = function (e) 0)
error = function (e) {print(paste("Error when sampling:", e$message));return(0)})
vals$maxcount<-max(hist(vals$distribution, plot=FALSE)$counts)
})
if (length(vals$distribution) == vals$total_iterations)
Expand Down Expand Up @@ -263,6 +268,14 @@ shinyServer(function(input, output, session) {
updateSelectInput(session, "m3", choices = cols, selected=3, label = label3)
updateSelectInput(session, "stratumc", choices = cols)
})
### Locks down randomization choice for some statistics
observe({
if(input$stat %in% c("smean", "ssd", "meandif", "Fstatistic",
"slope", "intercept", "corr", "ancova1", "ancova2"))
updateSelectInput(session, "type", choices = optionsRand[3])
else
updateSelectInput(session, "type", choices = optionsRand)
})
session$onSessionEnded(function() {
run_iter$suspend()
})
Expand Down
5 changes: 1 addition & 4 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ library(shiny)
optionsStat <- c("smean","ssd","meandif","Fstatistic","meandifc","srow",
"scol","intercept","slope","corr","ancova1","ancova2","custom")
names(optionsStat) <- tr(optionsStat)
##Randomization
optionsRand <- c("Normal", "Within rows", "Within columns", "Rows as units", "Columns as units")
names(optionsRand) <- tr(optionsRand)
# Original/Randomized switch
OriRand <- c("Original", "Randomized")
names(OriRand) <- tr(OriRand)
Expand Down Expand Up @@ -262,7 +259,7 @@ shinyUI(fluidPage(theme= "bootstrap.css",
sidebarPanel(
helpText(tr("Here is where we do the randomization!")),
selectInput("type", tr("Randomization type:"),
choices=optionsRand
choices=1
),
##Help for each randomization panel
conditionalPanel(
Expand Down

0 comments on commit 73c2d5e

Please sign in to comment.