diff --git a/lang.csv b/lang.csv index aaa5ef3..da6ef7c 100644 --- a/lang.csv +++ b/lang.csv @@ -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 diff --git a/server.R b/server.R index 3d57db0..5b73091 100644 --- a/server.R +++ b/server.R @@ -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)]) @@ -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){ @@ -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())) @@ -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) @@ -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() }) diff --git a/ui.R b/ui.R index de15e67..5123155 100644 --- a/ui.R +++ b/ui.R @@ -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) @@ -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(