Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3827 lines (3048 sloc)
189 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| title: Simulation | |
| author: '<a href="https://github.com/pablobernabeu/Experimental-data-simulation/" target="_blank"><button class="button-version">v `r app_version = read.delim("https://raw.githubusercontent.com/pablobernabeu/Experimental-data-simulation/master/version_number", header = FALSE)[1,1]; sprintf("%.1f", app_version) # Version number can be updated at https://github.com/pablobernabeu/Experimental-data-simulation/blob/master/version_number`</button></a>' | |
| output: | |
| flexdashboard::flex_dashboard: | |
| theme: 'spacelab' | |
| orientation: columns | |
| vertical_layout: scroll | |
| favicon: https://raw.githubusercontent.com/pablobernabeu/Experimental-data-simulation/master/Royalty-free%20from%20www.needpix.com.png | |
| runtime: shiny | |
| --- | |
| ```{r setup, include = FALSE} | |
| library(dplyr) | |
| library(DT) | |
| library(flexdashboard) | |
| library(htmltools) | |
| library(knitr) | |
| library(ngram) | |
| library(purrr) | |
| library(shiny) | |
| library(stringr) | |
| library(tidyr) | |
| knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE, error = FALSE) | |
| ``` | |
| <!-- Adjust website settings --> | |
| <head> | |
| <style type="text/css"> | |
| <!-- Tabs format --> | |
| /* tab, general */ | |
| ul.nav.navbar-nav.navbar-left a { | |
| color: white; | |
| background-color: none; | |
| border-bottom: none; | |
| } | |
| /* tab hovered over */ | |
| ul.nav.navbar-nav.navbar-left a:hover { | |
| color: white; | |
| background-color: #34507D; | |
| border-bottom: none; | |
| text-shadow: none; | |
| } | |
| /* active tab */ | |
| ul.nav.navbar-nav.navbar-left li.active a { | |
| color: white; | |
| font-weight: bold; | |
| background-color: #5472A3; | |
| border-bottom: 3px solid; | |
| text-shadow: none; | |
| } | |
| /* visited links in inactive tabs */ | |
| ul.nav.navbar-nav.navbar-left a:visited { | |
| color: white; | |
| font-weight: bold; | |
| background-color: #5472A3; | |
| border-bottom: none; | |
| text-shadow: none; | |
| } | |
| /* 'Data set' tab, general */ | |
| #navbar > ul.nav.navbar-nav.navbar-left > li:nth-child(9) > a { | |
| font-weight: bold; | |
| } | |
| /* 'Data set' tab, hovered over */ | |
| #navbar > ul.nav.navbar-nav.navbar-left > li:nth-child(9) > a:hover { | |
| color: black; | |
| background-color: #F0DFD0; | |
| } | |
| /* 'Data set' tab, active */ | |
| #navbar > ul.nav.navbar-nav.navbar-left > li:nth-child(9).active > a { | |
| color: black; | |
| background-color: #F0DFD0; | |
| } | |
| <!-- Fonts format --> | |
| body{ /* Normal */ | |
| font-size: 16px; | |
| } | |
| td { /* Table */ | |
| font-size: 14px; | |
| } | |
| h1.title { | |
| font-size: 38px; | |
| font-weight: bold; | |
| color: #28002E | |
| } | |
| h1 { /* Header 1 */ | |
| font-size: 28px; | |
| font-weight: bold; | |
| color: #28002E | |
| } | |
| h2 { /* Header 2 */ | |
| font-size: 22px; | |
| font-weight: bold; | |
| color: #28002E | |
| } | |
| h3 { /* Header 3 */ | |
| font-size: 18px; | |
| font-weight: bold; | |
| } | |
| h4 { /* Header 4 */ | |
| font-size: 16px; | |
| } | |
| h5 { /* Header 5 */ | |
| font-size: 15px; | |
| } | |
| h6 { /* Header 6 */ | |
| font-size: 14px; | |
| } | |
| code.r{ /* Code block */ | |
| font-size: 22px; | |
| } | |
| pre { /* Code-formatted output */ | |
| font-size: 14px; | |
| padding-top: 2px; | |
| padding-bottom: 2px; | |
| margin-top: -15px; | |
| margin-bottom: 18px; | |
| } | |
| /* Input fields */ | |
| .shiny-bound-input { | |
| font-size: 16px; | |
| color: #2D5054; | |
| } | |
| /* Change error messages */ | |
| .shiny-output-error{ | |
| visibility: hidden; | |
| padding-bottom: 10px; | |
| } | |
| .shiny-output-error:after{ | |
| content: 'Awaiting appropriate inputs or loading data.'; | |
| visibility: visible; color: #377277; font-size: 14px; | |
| padding-bottom: 20px; margin-bottom: 20px; | |
| } | |
| /* Format buttons */ | |
| .button-version { | |
| background-color: #FCF5F5; | |
| opacity: 0.2; | |
| border: none; | |
| color: black; | |
| font-weight: bold; | |
| padding: 0px 4px; | |
| text-align: center; | |
| text-decoration: none; | |
| display: inline-block; | |
| font-size: 10px; | |
| margin: 0px 0px; | |
| cursor: pointer; | |
| border-radius: 12px; | |
| } | |
| .button-version:hover { | |
| opacity: 1; | |
| } | |
| .button-samplesize { | |
| background-color: #474A67; | |
| border: none; | |
| padding: 3px 9px; | |
| text-align: center; | |
| text-decoration: none; | |
| display: inline-block; | |
| font-size: 14px; | |
| margin: 0px 3px; | |
| cursor: pointer; | |
| border-radius: 12px; | |
| } | |
| .button-samplesize:hover { | |
| background-color: #1B1B20; | |
| } | |
| .button-parameters-download { | |
| border: 1px solid black; | |
| background-color: #F4F9F9; | |
| color: black; | |
| padding: 3px 6px; | |
| cursor: pointer; | |
| border-color: #E4ECED; | |
| color: black; | |
| } | |
| .button-parameters-download:hover { | |
| background: #E9F2F2; | |
| color: black; | |
| } | |
| /* Format the 'Multiply N' input field */ | |
| #multiply_N.form-control.shiny-bound-input { | |
| padding-left: 20px; | |
| padding-top: 8px; | |
| padding-bottom: 8px; | |
| font-size: 150%; | |
| color: #932323; | |
| letter-spacing: 4px; | |
| } | |
| </style> | |
| <!-- Load Bootstrap libraries for icons --> | |
| <link rel='stylesheet' href='https://use.fontawesome.com/releases/v5.7.0/css/all.css' integrity='sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ' crossorigin='anonymous'> | |
| <!-- Javascript function to enable a hovering tooltip --> | |
| <script> | |
| $(document).ready(function(){ | |
| $('[data-toggle="tooltip1"]').tooltip(); | |
| }); | |
| </script> | |
| ////// Tooltip css styling | |
| $("#message").css({ | |
| 'font-size':'2px' | |
| }); | |
| </head> | |
| <i class="fas fa-info-circle" aria-hidden="true"></i> Home {style="background-color: #FEFEFE; data-width: 100%; width: 900px; margin: 0 auto;"} | |
| ======================================================================= | |
| Column {style='padding-top:30px;'} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-size:23px;'> **Web application for the simulation of experimental data**</span> | |
| <div style = "padding-top: 5px; padding-left: 60px; padding-right: 60px; font-size: 16px; line-height: 1.6;"> | |
| <div style='text-align:right; margin-bottom: -30px;'> | |
| <a href="http://creativecommons.org/licenses/by/4.0/" target="_blank" rel="Attribution licence" style="color:#CEC7BF; font-size:13px;"> Licence <img style="border-width:0;" src="https://i.creativecommons.org/l/by/4.0/80x15.png" alt="Creative Commons License"></img> </a> | |
| </div> | |
| <div style = 'font-size: 20px; color: #614064; padding-top: 10px; padding-bottom: 10px;'><i class="fas fa-chalkboard-teacher fa-xs" aria-hidden="true"></i> <i class="fas fa-university fa-xs" aria-hidden="true"></i> Purposes </div> | |
| This open-source, R-based web application is suitable for educational and research purposes in experimental and quantitative sciences. It allows the **creation of varied data sets with specified structures, such as between-group and within-participant variables, that can be categorical or continuous.** These parameters can be set throughout the various tabs (sections) from the top menu. In the last tab, the data set can be downloaded. The benefits of this application include time-saving and flexibility in the control of parameters. | |
| <h3>Guidelines</h3> | |
| General guidelines include the following: | |
| - **In the names of variables**, it's recommended only to use alphanumeric characters and underscore signs. The latter can be used to separate characters or words (e.g., *variable_name*). Different names should be used for each variable. | |
| - **In the levels of categorical variables**, alphanumeric, special characters and spaces are allowed. | |
| - **In numeric fields** (e.g., 'Mean', 'Standard deviation', 'Relative probability [0, 1]'), only numbers and decimal points are allowed. | |
| - **As the data set increases**, so does the processing time. | |
| More specific guidelines are available in each section. | |
| <div style='padding-top:8px; padding-bottom:11px; color:#665F5F;'> Screenshot of the *Dependent* tab ([view larger](https://github.com/pablobernabeu/Experimental-data-simulation/raw/master/Screenshot.png){target='_blank'}) </div> | |
| <img style="max-width: 750px; display: block; margin-left: auto; margin-right: auto; padding-bottom: 20px;" src="https://github.com/pablobernabeu/Experimental-data-simulation/raw/master/Screenshot.png" /> | |
| <h3>Rounding</h3> | |
| Below, you can select the **number of decimal places** to be kept in any continuous variables that you create. | |
| ```{r} | |
| numericInput('rounding', NULL, 3, min = 1, width = '60px') | |
| ``` | |
| <br> | |
| <h3>Ensuring reproducibility of simulated data</h3> | |
| Reproducing a simulation requires three pieces of data: the seed number, the parameter list and the final data set. After creating the variables wanted, make sure to download the parameter list and the final data set in the [last tab](#data-set). The seed number will be part of the names of the downloaded files. | |
| A seed number is a code that allows the reproducibility of any data involving random generation. This applies to any variables created in the *Individual* tab or in the *Dependent* tab. The number is shown below, where you can change it to any integer number up to ±`r .Machine$integer.max`. | |
| ```{r} | |
| tags$style(type = 'text/css', | |
| '#seed.form-control.shiny-bound-input {padding-left:40px; padding-top:8px; padding-bottom:8px; font-size:150%; color:#206B90; letter-spacing:6px;}') | |
| numericInput('seed', NULL, sample(1:99999, 1), step = 1, min = -.Machine$integer.max, max = .Machine$integer.max) | |
| ## Important notes about the seed ## | |
| # The seed from input$seed must be set right before any random sampling function, such as rnorm() or rbinom(), | |
| # using set.seed(input$seed). | |
| # To avoid creating systematic patterns across variables, which would limit the use of having different | |
| # variables (e.g., the correlations among continuous variables would be 1), each seed number must be in | |
| # turn multiplied by a different number. These multiplication factors have been sequentially assigned, | |
| # beginning from the Independent Categorical 2 variable (multiplication factor = 1) all the way down to | |
| # the Dependent Continuous 8 variable (multiplication factor = 32). These numbers cannot be set using a | |
| # function-based random number (e.g., using the 'sample()' function) because that would render the seed | |
| # number useless, due to the crossing of random numbers. | |
| ``` | |
| <br> | |
| <h3>Reference</h3> | |
| Bernabeu, P., & Lynott, D. (2020). *Web application for the simulation of experimental data* (Version `r sprintf("%.1f", app_version)`). [https://github.com/pablobernabeu/Experimental-data-simulation/](https://github.com/pablobernabeu/Experimental-data-simulation/){target='_blank'} | |
| <h3>Code</h3> | |
| This web application was developed in [R](https://www.r-project.org/about.html){target='_blank'} (R Core Team, 2020). The code is [available on Github](https://github.com/pablobernabeu/Experimental-data-simulation){target='_blank'}, where contributions may be made. The initial code for this application was influenced by Section 5.7 ([*Simulating data for multi-factor designs*](https://crumplab.github.io/programmingforpsych/simulating-and-analyzing-data-in-r.html#simulating-data-for-multi-factor-designs){target='_blank'}) in Crump (2017). The R packages used include 'dplyr' (Wickham, François, Henry, & Müller, 2018), 'DT' (Xie, 2020), 'flexdashboard' (Iannone, Allaire, & Borges, 2020), 'shiny' (Chang, Cheng, Allaire, Xie, & McPherson, 2020) and 'stringr' (Wickham, 2019). | |
| <br> | |
| <h3>Acknowledgements</h3> | |
| Thank you to RStudio for the free hosting server used by this application, [shinyapps.io](https://www.shinyapps.io/){target='_blank'}. | |
| <h3>References</h3> | |
| <div style = "text-indent:-1.5em; margin-left:1.5em;"> | |
| Chang, W., Cheng, J., Allaire, J., Xie, Y., & McPherson, J. (2020). shiny: Web Application Framework for R. R package version 1.4.0. Available at [http://CRAN.R-project.org/package=shiny](http://CRAN.R-project.org/package=shiny){target='_blank'}. | |
| Crump, M. J. C. (2017). Programming for Psychologists: Data Creation and Analysis (Version 1.1). [https://crumplab.github.io/programmingforpsych/](https://crumplab.github.io/programmingforpsych/){target='_blank'}. | |
| Iannone, R., Allaire, J. J., & Borges, B. (2020). Flexdashboard: R Markdown Format for Flexible Dashboards. [http://rmarkdown.rstudio.com/flexdashboard](http://rmarkdown.rstudio.com/flexdashboard){target='_blank'}. | |
| R Core Team (2020). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL [https://www.R-project.org/](https://www.R-project.org/){target='_blank'}. | |
| Wickham, H. (2019). stringr: Simple, Consistent Wrappers for Common String Operations. R package version 1.4.0. [https://CRAN.R-project.org/package=stringr](https://CRAN.R-project.org/package=stringr){target='_blank'}. | |
| Wickham, H., François, R., Henry, L., & Müller, K. (2018). dplyr: A Grammar of Data Manipulation. R package version 0.7.6. [https://CRAN.R-project.org/package=dplyr](https://CRAN.R-project.org/package=dplyr){target='_blank'}. | |
| Xie, Y. (2020). DT: A Wrapper of the JavaScript Library "DataTables". R package version 0.14. Available at [https://CRAN.R-project.org/package=DT](https://CRAN.R-project.org/package=DT){target='_blank'}. | |
| </div> | |
| <h3>Contact</h3> | |
| To submit any questions or feedback, please post a [GitHub issue](https://github.com/pablobernabeu/Experimental-data-simulation/issues){target='_blank'}, or email Pablo Bernabeu at [p.bernabeu@lancaster.ac.uk](mailto:p.bernabeu@lancaster.ac.uk){target='_blank'}. | |
| <br> | |
| <br> | |
| </div> | |
| Groups | |
| ======================================================================= | |
| Column {style="margin-top:20px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-size:18px; color:#4D4F54;'> Groups and number of participants per group </span> | |
| <br> | |
| ```{r} | |
| groups_structure = | |
| reactive({ | |
| x = final_dataset() %>% | |
| # Remove all columns except groups | |
| select(-any_of(c(input$name_Participant_column, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_WithinParticipant1, input$name_WithinParticipant2, | |
| input$name_WithinParticipant3, input$name_WithinParticipant4, | |
| input$name_WithinParticipant5, input$name_WithinParticipant6, | |
| input$name_WithinParticipant7, input$name_WithinParticipant8, | |
| input$name_Trial_column, input$name_Extra_nested_column, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>% | |
| # This first bit displays number of observations per cell ('n') | |
| group_by(across(any_of( | |
| final_dataset() %>% select(-input$name_Participant_column) %>% | |
| select_if(~is.factor(.) | is.character(.)) %>% names() | |
| ))) %>% tally %>% | |
| # Merge the previous basic structure with the columns that are relevant now | |
| merge( | |
| final_dataset() %>% | |
| # Remove all columns except groups and those variables created inside this tab | |
| select(-any_of(c(input$name_Participant_column, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_WithinParticipant1, input$name_WithinParticipant2, | |
| input$name_WithinParticipant3, input$name_WithinParticipant4, | |
| input$name_WithinParticipant5, input$name_WithinParticipant6, | |
| input$name_WithinParticipant7, input$name_WithinParticipant8, | |
| input$name_Trial_column, input$name_Extra_nested_column, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>% | |
| group_by(across(any_of( | |
| final_dataset() %>% | |
| select(-any_of(c(input$name_Participant_column, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_WithinParticipant1, input$name_WithinParticipant2, | |
| input$name_WithinParticipant3, input$name_WithinParticipant4, | |
| input$name_WithinParticipant5, input$name_WithinParticipant6, | |
| input$name_WithinParticipant7, input$name_WithinParticipant8, | |
| input$name_Trial_column, input$name_Extra_nested_column, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>% | |
| select_if(~is.factor(.) | is.character(.)) %>% names() | |
| ))) %>% tally %>% | |
| # Order columns in standard order, which is important for the setting of parameters within factor levels | |
| select(any_of(c( | |
| input$name_Participant_column, | |
| input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_WithinParticipant1, input$name_WithinParticipant2, input$name_WithinParticipant3, | |
| input$name_Trial_column, input$name_Extra_nested_column, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8 | |
| ))) %>% | |
| # Remove duplicate rows | |
| unique() | |
| ) | |
| }) | |
| renderDT({ | |
| datatable(groups_structure(), class = 'nowrap compact cell-border', selection = 'none', | |
| options = list(order = list(1, 'asc'), dom = 'rt', scroller = TRUE, ordering = FALSE, | |
| pageLength = nrow(groups_structure())), | |
| # Fixed row names (source: https://stackoverflow.com/questions/55115183/r-dt-datatable-not-retaining-row-index-counter-column-after-selecting-new-page-w/55125758#55125758) | |
| callback = JS(c( | |
| "table.on('draw.dt', function(){", | |
| " var PageInfo = table.page.info();", | |
| " table.column(0, {page: 'current'}).nodes().each(function(cell,i){", | |
| " cell.innerHTML = i + 1 + PageInfo.start;", | |
| " });", | |
| "})" | |
| ))) %>% | |
| formatStyle(0, Color = '#595143', backgroundColor = '#EFF1F8') | |
| }) | |
| ``` | |
| Column {style="margin-top:20px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-weight:bold; font-size:15px; color:#0E6D00;'>Between-group 1</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_BetweenGroup1', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group1', NULL, placeholder = 'Level 1') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group2', NULL, placeholder = 'Level 2') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group3', NULL, placeholder = 'Level 3') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group4', NULL, placeholder = 'Level 4') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group5', NULL, placeholder = 'Level 5') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group6', NULL, placeholder = 'Level 6') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group7', NULL, placeholder = 'Level 7') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group8', NULL, placeholder = 'Level 8') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group9', NULL, placeholder = 'Level 9') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group10', NULL, placeholder = 'Level 10') | |
| ``` | |
| Column {style="margin-top:20px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-weight:bold; font-size:15px; color:#001AB3;'>Between-group 2</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_BetweenGroup2', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group1', NULL, placeholder = 'Level 1') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group2', NULL, placeholder = 'Level 2') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group3', NULL, placeholder = 'Level 3') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group4', NULL, placeholder = 'Level 4') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group5', NULL, placeholder = 'Level 5') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group6', NULL, placeholder = 'Level 6') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group7', NULL, placeholder = 'Level 7') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group8', NULL, placeholder = 'Level 8') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group9', NULL, placeholder = 'Level 9') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group10', NULL, placeholder = 'Level 10') | |
| ``` | |
| Column {style="margin-top:20px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-weight:bold; font-size:15px; color:#B32600;'>Between-group 3</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_BetweenGroup3', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group1', NULL, placeholder = 'Level 1') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group2', NULL, placeholder = 'Level 2') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group3', NULL, placeholder = 'Level 3') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group4', NULL, placeholder = 'Level 4') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group5', NULL, placeholder = 'Level 5') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group6', NULL, placeholder = 'Level 6') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group7', NULL, placeholder = 'Level 7') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group8', NULL, placeholder = 'Level 8') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group9', NULL, placeholder = 'Level 9') | |
| textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group10', NULL, placeholder = 'Level 10') | |
| ``` | |
| Individual | |
| ======================================================================= | |
| Column {style="margin-top:20px; padding-top:10px; max-width:700px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-size:18px; color:#4D4F54;'> **Groups structure to guide parameter setting**</span> | |
| <br> | |
| ```{r} | |
| Individual_factorial_structure = | |
| reactive({ | |
| x = final_dataset() %>% | |
| # Remove all columns except groups | |
| select(-any_of(c(input$name_Participant_column, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_WithinParticipant1, input$name_WithinParticipant2, | |
| input$name_WithinParticipant3, input$name_WithinParticipant4, | |
| input$name_WithinParticipant5, input$name_WithinParticipant6, | |
| input$name_WithinParticipant7, input$name_WithinParticipant8, | |
| input$name_Trial_column, input$name_Extra_nested_column, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>% | |
| # This first bit displays number of observations per cell ('n') | |
| group_by(across(any_of( | |
| final_dataset() %>% select(-input$name_Participant_column) %>% | |
| select_if(~is.factor(.) | is.character(.)) %>% names() | |
| ))) %>% tally %>% | |
| # Merge the previous basic structure with the columns that are relevant now | |
| merge( | |
| final_dataset() %>% | |
| # Remove all columns except groups and those variables created inside this tab | |
| select(-any_of(c(input$name_Participant_column, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_WithinParticipant1, input$name_WithinParticipant2, | |
| input$name_WithinParticipant3, input$name_WithinParticipant4, | |
| input$name_WithinParticipant5, input$name_WithinParticipant6, | |
| input$name_WithinParticipant7, input$name_WithinParticipant8, | |
| input$name_Trial_column, input$name_Extra_nested_column, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>% | |
| group_by(across(any_of( | |
| final_dataset() %>% | |
| select(-any_of(c(input$name_Participant_column, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_WithinParticipant1, input$name_WithinParticipant2, | |
| input$name_WithinParticipant3, input$name_WithinParticipant4, | |
| input$name_WithinParticipant5, input$name_WithinParticipant6, | |
| input$name_WithinParticipant7, input$name_WithinParticipant8, | |
| input$name_Trial_column, input$name_Extra_nested_column, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>% | |
| select_if(~is.factor(.) | is.character(.)) %>% names() | |
| ))) %>% tally %>% | |
| # Order columns in standard order, which is important for the setting of parameters within factor levels | |
| select(any_of(c( | |
| input$name_Participant_column, | |
| input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_WithinParticipant1, input$name_WithinParticipant2, input$name_WithinParticipant3, | |
| input$name_Trial_column, input$name_Extra_nested_column, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8 | |
| ))) %>% | |
| # Remove duplicate rows | |
| unique() | |
| ) | |
| }) | |
| renderDT({ | |
| datatable(Individual_factorial_structure(), class = 'nowrap compact cell-border', selection = 'none', | |
| options = list(order = list(1, 'asc'), dom = 'rt', scroller = TRUE, ordering = FALSE, | |
| pageLength = nrow(Individual_factorial_structure())), | |
| # Fixed row names (source: https://stackoverflow.com/questions/55115183/r-dt-datatable-not-retaining-row-index-counter-column-after-selecting-new-page-w/55125758#55125758) | |
| callback = JS(c( | |
| "table.on('draw.dt', function(){", | |
| " var PageInfo = table.page.info();", | |
| " table.column(0, {page: 'current'}).nodes().each(function(cell,i){", | |
| " cell.innerHTML = i + 1 + PageInfo.start;", | |
| " });", | |
| "})" | |
| ))) %>% | |
| formatStyle(0, Color = '#595143', backgroundColor = '#EFF1F8') | |
| }) | |
| ``` | |
| <br> | |
| <div style = 'padding-left: 40px; padding-right: 40px; padding-top: 15px; padding-bottom: 20px; background-color: #FEFEFE; font-size: 16px; line-height: 1.6;'> | |
| The parameters for the dependent variables may be set generally for the whole data set. However, the parameters may also be adjusted by group ([tab](#groups)), if any groups have been created. Where any groups exist, they will constitute a factorial structure that will be displayed in the table above. Each row corresponds to a *cell* in that structure. | |
| **Categorical variables.** This is a pseudorandom variable. Thus, it differs from *Groups* in that the categories are assigned to each cell following a probability input entered by the user (programming detail: using `rbinom()`). This input can range from 0 to 1. Values toward 0 increase the proportions of levels entered first, and values toward 1 increase the levels entered last. Where any groups exist (created in the Groups tab), to adjust the frequency of each level in the factors below per group, multiple probability values may be entered, separated by commas, each corresponding to a group. For instance, with four groups, the levels of a categorical independent variable could be entered as 'A, B, C', and the probabilities as $.2, .8, .4, .7$. This would mean that the most frequent level in Groups 1 to 4, respectively, would be A, C, B, and B. This variable does not add to the general factorial structure, unlike *Groups*. | |
| **Continuous variables.** Where any groups exist (created in the Groups tab), to adjust the means and standard deviations for each group, multiple values may be entered, separated by commas, each corresponding to a group. For instance, with four groups, the means could be entered as $34, 543, 657, 123$, and the standard deviations as $10, 20, 25, 5$. | |
| Since both of these variables use randomisation, the user's parameters will be more closely approached with larger samples ([adjust](#sample)). The overall summary, including the dependent variables, is shown below. | |
| </div> | |
| ### **Summary including any individual variables** ([more summary options](#summary)) | |
| ```{r} | |
| factorial_structure_with_individual_variables = | |
| reactive({ | |
| x = final_dataset() %>% | |
| # Remove all columns except groups and those variables created inside this tab | |
| select(any_of(c(input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8))) %>% | |
| # This first bit displays number of observations per cell ('n') | |
| group_by(across(any_of( | |
| final_dataset() %>% | |
| select(-any_of(c(input$name_Participant_column))) %>% | |
| select_if(~is.factor(.) | is.character(.)) %>% names() | |
| ))) %>% tally %>% | |
| # Merge the previous basic structure with the columns that are relevant now | |
| merge( | |
| final_dataset() %>% | |
| # Remove all columns except groups and those variables created inside this tab | |
| select(any_of(c(input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8))) %>% | |
| group_by(across(any_of( | |
| final_dataset() %>% | |
| select(any_of(c(input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8))) %>% | |
| select_if(~is.factor(.) | is.character(.)) %>% names() | |
| ))) | |
| ) | |
| # If there aren't any numeric variables in the subset, just present the factors | |
| if(!isTruthy(input$name_Continuous_Independent1)) { | |
| summary = | |
| x %>% group_by(across(any_of( | |
| c(input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8) | |
| ))) | |
| } else # If there are any numeric variables in the subset, summarise data across factors | |
| summary = | |
| x %>% | |
| group_by(across(any_of( | |
| c(input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3)))) %>% | |
| summarise(across(any_of( | |
| final_dataset() %>% | |
| select(any_of(c(input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8))) %>% | |
| select_if(~is.numeric(.)) %>% names()), | |
| list(Mean = mean, SD = sd))) | |
| merge(x, summary) %>% | |
| select(-any_of(c(input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8))) %>% | |
| unique %>% | |
| # Round off numeric variables | |
| mutate(across(where(is.numeric), round, input$rounding)) | |
| }) | |
| renderDT( | |
| datatable(factorial_structure_with_individual_variables(), class = 'nowrap compact cell-border', selection = 'none', | |
| options = list(order = list(1, 'asc'), dom = 'rt', scroller = TRUE, ordering = FALSE, | |
| pageLength = nrow(factorial_structure_with_individual_variables())), | |
| # Fixed row names (source: https://stackoverflow.com/questions/55115183/r-dt-datatable-not-retaining-row-index-counter-column-after-selecting-new-page-w/55125758#55125758) | |
| callback = JS(c( | |
| "table.on('draw.dt', function(){", | |
| " var PageInfo = table.page.info();", | |
| " table.column(0, {page: 'current'}).nodes().each(function(cell,i){", | |
| " cell.innerHTML = i + 1 + PageInfo.start;", | |
| " });", | |
| "})" | |
| ))) %>% | |
| formatStyle(0, Color = '#595143', backgroundColor = '#EFF1F8') | |
| ) | |
| ``` | |
| Column {style="margin-top:30px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 1</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent1', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent1', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent1', NULL, placeholder = 'Relative probability [0, 1] (per group)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent1)) { | |
| cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Independent1() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Independent1()) / sum(table(Categorical_Independent1())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 2</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent2', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent2', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent2', NULL, placeholder = 'Relative probability [0, 1] (per group)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent2)) { | |
| cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Independent2() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Independent2()) / sum(table(Categorical_Independent2())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 3</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent3', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent3', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent3', NULL, placeholder = 'Relative probability [0, 1] (per group)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent3)) { | |
| cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Independent3() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Independent3()) / sum(table(Categorical_Independent3())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 4</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent4', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent4', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent4', NULL, placeholder = 'Relative probability [0, 1] (per group)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent4)) { | |
| cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Independent4() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Independent4()) / sum(table(Categorical_Independent4())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 5</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent5', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent5', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent5', NULL, placeholder = 'Relative probability [0, 1] (per group)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent5)) { | |
| cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Independent5() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Independent5()) / sum(table(Categorical_Independent5())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 6</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent6', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent6', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent6', NULL, placeholder = 'Relative probability [0, 1] (per group)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent6)) { | |
| cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Independent6() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Independent6()) / sum(table(Categorical_Independent6())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 7</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent7', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent7', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent7', NULL, placeholder = 'Relative probability [0, 1] (per group)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent7)) { | |
| cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Independent7() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Independent7()) / sum(table(Categorical_Independent7())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 8</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent8', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent8', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent8', NULL, placeholder = 'Relative probability [0, 1] (per group)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent8)) { | |
| cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Independent8() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Independent8()) / sum(table(Categorical_Independent8())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ```{r} | |
| # Count all Categorical_Independent levels | |
| levels_Categorical_Independent = reactive({ | |
| if(length(levels(Categorical_Independent1())) < 2) { | |
| x = 1 | |
| } | |
| if(length(levels(Categorical_Independent1())) > 1) { | |
| x = length(levels(Categorical_Independent1())) | |
| } | |
| if(length(levels(Categorical_Independent2())) > 1) { | |
| x = x * length(levels(Categorical_Independent2())) | |
| } | |
| if(length(levels(Categorical_Independent3())) > 1) { | |
| x = x * length(levels(Categorical_Independent3())) | |
| } | |
| if(length(levels(Categorical_Independent4())) > 1) { | |
| x = x * length(levels(Categorical_Independent4())) | |
| } | |
| if(length(levels(Categorical_Independent5())) > 1) { | |
| x = x * length(levels(Categorical_Independent5())) | |
| } | |
| if(length(levels(Categorical_Independent6())) > 1) { | |
| x = x * length(levels(Categorical_Independent6())) | |
| } | |
| if(length(levels(Categorical_Independent7())) > 1) { | |
| x = x * length(levels(Categorical_Independent7())) | |
| } | |
| if(length(levels(Categorical_Independent8())) > 1) { | |
| x = x * length(levels(Categorical_Independent8())) | |
| } | |
| x | |
| }) | |
| ``` | |
| Column {style="margin-top:30px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 1</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Independent1', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent1_mean', NULL, placeholder = 'Mean (per group)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent1_SD', NULL, placeholder = 'Standard deviation (per group)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 2</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Independent2', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent2_mean', NULL, placeholder = 'Mean (per group)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent2_SD', NULL, placeholder = 'Standard deviation (per group)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 3</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Independent3', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent3_mean', NULL, placeholder = 'Mean (per group)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent3_SD', NULL, placeholder = 'Standard deviation (per group)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 4</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Independent4', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent4_mean', NULL, placeholder = 'Mean (per group)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent4_SD', NULL, placeholder = 'Standard deviation (per group)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 5</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Independent5', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent5_mean', NULL, placeholder = 'Mean (per group)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent5_SD', NULL, placeholder = 'Standard deviation (per group)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 6</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Independent6', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent6_mean', NULL, placeholder = 'Mean (per group)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent6_SD', NULL, placeholder = 'Standard deviation (per group)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 7</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Independent7', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent7_mean', NULL, placeholder = 'Mean (per group)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent7_SD', NULL, placeholder = 'Standard deviation (per group)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 8</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Independent8', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent8_mean', NULL, placeholder = 'Mean (per group)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Independent8_SD', NULL, placeholder = 'Standard deviation (per group)') | |
| ``` | |
| Conditions | |
| ======================================================================= | |
| Column {style="margin-top:20px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-size:18px; color:#4D4F54;'> **Complete factorial structure**</span> | |
| <br> | |
| ```{r} | |
| factorial_structure = | |
| reactive({ | |
| x = final_dataset() %>% | |
| # Remove all columns except groups | |
| select(-any_of(c(input$name_Participant_column, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>% | |
| # This first bit displays number of observations per cell ('n') | |
| group_by(across(any_of( | |
| final_dataset() %>% select(-input$name_Participant_column) %>% | |
| select_if(~is.factor(.) | is.character(.)) %>% names() | |
| ))) %>% tally %>% | |
| # Merge the previous basic structure with the columns that are relevant now | |
| merge( | |
| final_dataset() %>% | |
| # Remove all columns except groups and those variables created inside this tab | |
| select(-any_of(c(input$name_Participant_column, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>% | |
| group_by(across(any_of( | |
| final_dataset() %>% | |
| select(-any_of(c(input$name_Participant_column, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>% | |
| select_if(~is.factor(.) | is.character(.)) %>% names() | |
| ))) %>% tally %>% | |
| # Order columns in standard order, which is important for the setting of parameters within factor levels | |
| select(any_of(c( | |
| input$name_Participant_column, | |
| input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_WithinParticipant1, input$name_WithinParticipant2, input$name_WithinParticipant3, | |
| input$name_Trial_column, input$name_Extra_nested_column, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8 | |
| ))) %>% | |
| # Remove duplicate rows | |
| unique() | |
| ) | |
| }) | |
| renderDT({ | |
| datatable(factorial_structure(), class = 'nowrap compact cell-border', selection = 'none', | |
| options = list(order = list(1, 'asc'), dom = 'rt', scroller = TRUE, ordering = FALSE, | |
| pageLength = nrow(factorial_structure())), | |
| # Fixed row names (source: https://stackoverflow.com/questions/55115183/r-dt-datatable-not-retaining-row-index-counter-column-after-selecting-new-page-w/55125758#55125758) | |
| callback = JS(c( | |
| "table.on('draw.dt', function(){", | |
| " var PageInfo = table.page.info();", | |
| " table.column(0, {page: 'current'}).nodes().each(function(cell,i){", | |
| " cell.innerHTML = i + 1 + PageInfo.start;", | |
| " });", | |
| "})" | |
| ))) %>% | |
| formatStyle(0, Color = '#595143', backgroundColor = '#EFF1F8') | |
| }) | |
| ``` | |
| Column {style="margin-top:20px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-weight:bold; font-size:15px; color:#0E6D00;'>Within-participant 1</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_WithinParticipant1', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant1_Condition1', NULL, placeholder = 'Level 1') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant1_Condition2', NULL, placeholder = 'Level 2') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant1_Condition3', NULL, placeholder = 'Level 3') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant1_Condition4', NULL, placeholder = 'Level 4') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant1_Condition5', NULL, placeholder = 'Level 5') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant1_Condition6', NULL, placeholder = 'Level 6') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant1_Condition7', NULL, placeholder = 'Level 7') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant1_Condition8', NULL, placeholder = 'Level 8') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant1_Condition9', NULL, placeholder = 'Level 9') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant1_Condition10', NULL, placeholder = 'Level 10') | |
| ``` | |
| Column {style="margin-top:20px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-weight:bold; font-size:15px; color:#001AB3;'>Within-participant 2</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_WithinParticipant2', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant2_Condition1', NULL, placeholder = 'Level 1') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant2_Condition2', NULL, placeholder = 'Level 2') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant2_Condition3', NULL, placeholder = 'Level 3') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant2_Condition4', NULL, placeholder = 'Level 4') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant2_Condition5', NULL, placeholder = 'Level 5') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant2_Condition6', NULL, placeholder = 'Level 6') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant2_Condition7', NULL, placeholder = 'Level 7') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant2_Condition8', NULL, placeholder = 'Level 8') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant2_Condition9', NULL, placeholder = 'Level 9') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant2_Condition10', NULL, placeholder = 'Level 10') | |
| ``` | |
| Column {style="margin-top:20px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-weight:bold; font-size:15px; color:#B32600;'>Within-participant 3</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_WithinParticipant3', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant3_Condition1', NULL, placeholder = 'Level 1') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant3_Condition2', NULL, placeholder = 'Level 2') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant3_Condition3', NULL, placeholder = 'Level 3') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant3_Condition4', NULL, placeholder = 'Level 4') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant3_Condition5', NULL, placeholder = 'Level 5') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant3_Condition6', NULL, placeholder = 'Level 6') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant3_Condition7', NULL, placeholder = 'Level 7') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant3_Condition8', NULL, placeholder = 'Level 8') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant3_Condition9', NULL, placeholder = 'Level 9') | |
| textAreaInput(height = '45px', resize = 'vertical', 'WithinParticipant3_Condition10', NULL, placeholder = 'Level 10') | |
| ``` | |
| <i class="fas fa-plus" aria-hidden="true"></i> Nested {style="background-color: #FCFCFC; data-width: 100%; width: 900px; margin: 0 auto;"} | |
| ======================================================================= | |
| Column {style="padding-left: 50px;"} | |
| ----------------------------------------------------------------------- | |
| <div style = 'padding-left: 40px; padding-right: 40px; padding-top: 20px; padding-bottom: 20px; background-color: #FEFEFE; font-size: 16px; line-height: 1.6;'> | |
| <h3>More nested factors</h3> | |
| Additional nested factors such as trials can be entered. Their names and length can be adjusted below. These factors add to the general factorial structure, which is relevant to the setting of any variables in the *Dependent* tab. | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Trial_column', '', value = 'Trial') | |
| checkboxInput('include_Trial_column', 'Include this nested factor (un/check)', value = FALSE) | |
| numericInput('trial_N', 'Number of levels', 2, min = 1) | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Extra_nested_column', '', value = 'Extra_nested') | |
| checkboxInput('include_Extra_nested_column', 'Include this nested factor (un/check)', value = FALSE) | |
| numericInput('Extra_nested_N', 'Number of levels', 2, min = 1) | |
| ``` | |
| </div> | |
| Dependent | |
| ======================================================================= | |
| Column {style="margin-top:20px; padding-top:10px; max-width:700px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-size:18px; color:#4D4F54;'> **Factorial structure to guide parameter setting**</span> | |
| <br> | |
| ```{r} | |
| renderDT({ | |
| datatable(factorial_structure(), class = 'nowrap compact cell-border', selection = 'none', | |
| options = list(order = list(1, 'asc'), dom = 'rt', scroller = TRUE, ordering = FALSE, | |
| pageLength = nrow(factorial_structure())), | |
| # Fixed row names (source: https://stackoverflow.com/questions/55115183/r-dt-datatable-not-retaining-row-index-counter-column-after-selecting-new-page-w/55125758#55125758) | |
| callback = JS(c( | |
| "table.on('draw.dt', function(){", | |
| " var PageInfo = table.page.info();", | |
| " table.column(0, {page: 'current'}).nodes().each(function(cell,i){", | |
| " cell.innerHTML = i + 1 + PageInfo.start;", | |
| " });", | |
| "})" | |
| ))) %>% | |
| formatStyle(0, Color = '#595143', backgroundColor = '#EFF1F8') | |
| }) | |
| ``` | |
| <br> | |
| <div style = 'padding-left: 40px; padding-right: 40px; padding-top: 15px; padding-bottom: 20px; background-color: #FEFEFE; font-size: 16px; line-height: 1.6;'> | |
| The parameters for the dependent variables may be set generally for the whole data set. However, the parameters may also be adjusted by group ([tab](#groups)), condition ([tab](#conditions)), or other nested factors ([tab](#nested)), if any of those have been created. Where any such factors exist, they will constitute a factorial structure that will be displayed in the table above. Each row corresponds to a *cell* in that structure. | |
| **Categorical variables.** This is a pseudorandom variable. That is, the categories are assigned to each cell following a probability input entered by the user (programming detail: using `rbinom()`). This input can range from 0 to 1. Values toward 0 increase the proportions of levels entered first, and values toward 1 increase the levels entered last. To adjust the frequency of each level in each cell of the design (see above), multiple probability values may be entered, separated by commas, each corresponding to a cell. For instance, with a 2x2 design (four cells), the levels of a categorical dependent variable could be entered as 'correct, incorrect, unresponded', and the probabilities as $.2, .8, .4, .7$. This would mean that the most frequent level in Cells 1 to 4, respectively, would be 'correct', 'unresponded', 'incorrect', and 'unresponded'. | |
| **Continuous variables.** To adjust the means and standard deviations for each cell, multiple values may be entered, separated by commas, each corresponding to a cell. For instance, with a 2x2 design (four cells), the means could be entered as $34, 543, 657, 123$, and the standard deviations as $10, 20, 25, 5$. | |
| Since both of these variables use randomisation, the user's parameters will be more closely approached with larger samples ([adjust](#sample)). The overall summary, including the dependent variables, is shown below. | |
| </div> | |
| ### **General summary of data set** ([more summary options](#summary)) | |
| ```{r} | |
| Dependent_tab_summary = | |
| reactive({ | |
| # If no numeric variables present | |
| if(final_dataset() %>% select(-input$name_Participant_column) %>% select_if(is.numeric) %>% ncol == 0) { | |
| x = final_dataset() %>% | |
| # Remove base ID column (i.e., Participant) | |
| select(-input$name_Participant_column) %>% | |
| # This first bit displays number of observations per cell ('n') | |
| group_by(across(any_of( | |
| final_dataset() %>% select(-input$name_Participant_column) %>% select_if(~is.factor(.) | is.character(.)) %>% names() | |
| ))) %>% tally | |
| } else { # If any continuous variables present | |
| x = final_dataset() %>% | |
| # Remove base ID column (i.e., Participant) | |
| select(-input$name_Participant_column) %>% | |
| # This first bit displays number of observations per cell ('n') | |
| group_by(across(any_of( | |
| final_dataset() %>% select(-input$name_Participant_column) %>% select_if(~is.factor(.) | is.character(.)) %>% names() | |
| ))) %>% tally %>% | |
| # Merge the previous basic structure with the columns that are relevant now | |
| merge( | |
| final_dataset() %>% | |
| # Remove base ID column (i.e., Participant) | |
| select(-input$name_Participant_column) %>% | |
| group_by(across(any_of( | |
| final_dataset() %>% select(-input$name_Participant_column) %>% select_if(~is.factor(.) | is.character(.)) %>% names() | |
| ))) %>% | |
| summarise(across(any_of( | |
| final_dataset() %>% select(-input$name_Participant_column) %>% select_if(is.numeric) %>% names() | |
| ), list(Mean = mean, SD = sd))) %>% | |
| # Round off numeric variables | |
| mutate(across(where(is.numeric), round, input$rounding)) | |
| ) | |
| } | |
| }) | |
| renderDT( | |
| datatable(Dependent_tab_summary(), class = 'nowrap compact cell-border', selection = 'none', | |
| options = list(order = list(1, 'asc'), dom = 'rt', scroller = TRUE, ordering = FALSE, | |
| pageLength = nrow(Dependent_tab_summary())), | |
| # Fixed row names (source: https://stackoverflow.com/questions/55115183/r-dt-datatable-not-retaining-row-index-counter-column-after-selecting-new-page-w/55125758#55125758) | |
| callback = JS(c( | |
| "table.on('draw.dt', function(){", | |
| " var PageInfo = table.page.info();", | |
| " table.column(0, {page: 'current'}).nodes().each(function(cell,i){", | |
| " cell.innerHTML = i + 1 + PageInfo.start;", | |
| " });", | |
| "})" | |
| ))) %>% | |
| formatStyle(0, Color = '#595143', backgroundColor = '#EFF1F8') | |
| ) | |
| ``` | |
| Column {style="margin-top:30px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 1</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Dependent1', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Dependent1', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Dependent1', NULL, placeholder = 'Relative probability [0, 1] (per cell)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent1)) { | |
| cat('\nOverall proportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Dependent1() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Dependent1()) / sum(table(Categorical_Dependent1())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 2</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Dependent2', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Dependent2', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Dependent2', NULL, placeholder = 'Relative probability [0, 1] (per cell)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent2)) { | |
| cat('\nOverall proportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Dependent2() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Dependent2()) / sum(table(Categorical_Dependent2())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 3</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Dependent3', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Dependent3', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Dependent3', NULL, placeholder = 'Relative probability [0, 1] (per cell)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent3)) { | |
| cat('\nOverall proportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Dependent3() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Dependent3()) / sum(table(Categorical_Dependent3())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 4</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Dependent4', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Dependent4', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Dependent4', NULL, placeholder = 'Relative probability [0, 1] (per cell)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent4)) { | |
| cat('\nOverall proportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Dependent4() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Dependent4()) / sum(table(Categorical_Dependent4())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 5</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Dependent5', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Dependent5', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Dependent5', NULL, placeholder = 'Relative probability [0, 1] (per cell)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent5)) { | |
| cat('\nOverall proportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Dependent5() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Dependent5()) / sum(table(Categorical_Dependent5())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 6</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Dependent6', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Dependent6', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Dependent6', NULL, placeholder = 'Relative probability [0, 1] (per cell)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent6)) { | |
| cat('\nOverall proportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Dependent6() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Dependent6()) / sum(table(Categorical_Dependent6())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 7</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Dependent7', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Dependent7', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Dependent7', NULL, placeholder = 'Relative probability [0, 1] (per cell)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent7)) { | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| cat('\nOverall proportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Dependent7() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Dependent7()) / sum(table(Categorical_Dependent7())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 8</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Dependent8', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Dependent8', NULL, placeholder = 'Levels') | |
| textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Dependent8', NULL, placeholder = 'Relative probability [0, 1] (per cell)') | |
| # The code below will display a summary of the variable designed by the user. | |
| # Note that the variable is actually created and saved further below (see '# Create final data set'). | |
| reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent8)) { | |
| cat('\nOverall proportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n') | |
| Categorical_Dependent8() %>% levels() %>% trimws() %>% | |
| paste0(., ': ', (table(Categorical_Dependent8()) / sum(table(Categorical_Dependent8())) * 100) %>% | |
| round(digits = 2), '%', collapse = '\n') %>% | |
| str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat() | |
| cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n", | |
| "\nSee summary table for proportions per cell.\n_") | |
| } | |
| }) | |
| ``` | |
| ```{r} | |
| levels_Categorical_Dependent = reactive({ | |
| if(length(levels(Categorical_Dependent1())) < 2) { | |
| x = 1 | |
| } | |
| if(length(levels(Categorical_Dependent1())) > 1) { | |
| x = length(levels(Categorical_Dependent1())) | |
| } | |
| if(length(levels(Categorical_Dependent2())) > 1) { | |
| x = x * length(levels(Categorical_Dependent2())) | |
| } | |
| if(length(levels(Categorical_Dependent3())) > 1) { | |
| x = x * length(levels(Categorical_Dependent3())) | |
| } | |
| if(length(levels(Categorical_Dependent4())) > 1) { | |
| x = x * length(levels(Categorical_Dependent4())) | |
| } | |
| if(length(levels(Categorical_Dependent5())) > 1) { | |
| x = x * length(levels(Categorical_Dependent5())) | |
| } | |
| if(length(levels(Categorical_Dependent6())) > 1) { | |
| x = x * length(levels(Categorical_Dependent6())) | |
| } | |
| if(length(levels(Categorical_Dependent7())) > 1) { | |
| x = x * length(levels(Categorical_Dependent7())) | |
| } | |
| if(length(levels(Categorical_Dependent8())) > 1) { | |
| x = x * length(levels(Categorical_Dependent8())) | |
| } | |
| x | |
| }) | |
| ``` | |
| Column {style="margin-top:30px"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 1</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Dependent1', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent1_mean', NULL, placeholder = 'Mean (per cell)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent1_SD', NULL, placeholder = 'Standard deviation (per cell)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 2</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Dependent2', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent2_mean', NULL, placeholder = 'Mean (per cell)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent2_SD', NULL, placeholder = 'Standard deviation (per cell)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 3</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Dependent3', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent3_mean', NULL, placeholder = 'Mean (per cell)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent3_SD', NULL, placeholder = 'Standard deviation (per cell)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 4</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Dependent4', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent4_mean', NULL, placeholder = 'Mean (per cell)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent4_SD', NULL, placeholder = 'Standard deviation (per cell)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 5</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Dependent5', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent5_mean', NULL, placeholder = 'Mean (per cell)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent5_SD', NULL, placeholder = 'Standard deviation (per cell)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 6</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Dependent6', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent6_mean', NULL, placeholder = 'Mean (per cell)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent6_SD', NULL, placeholder = 'Standard deviation (per cell)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 7</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Dependent7', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent7_mean', NULL, placeholder = 'Mean (per cell)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent7_SD', NULL, placeholder = 'Standard deviation (per cell)') | |
| ``` | |
| ### <span style='font-weight:bold; font-size:15px; color:#781A74;'>Continuous 8</span> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Continuous_Dependent8', NULL, placeholder = 'Variable name') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent8_mean', NULL, placeholder = 'Mean (per cell)') | |
| textAreaInput(height = '45px', resize = 'vertical', 'Continuous_Dependent8_SD', NULL, placeholder = 'Standard deviation (per cell)') | |
| ``` | |
| ```{r} | |
| # Create final data set | |
| # Participant | |
| # Compute initial N as the product of any between-group levels | |
| final_N = reactive({ | |
| # Final N is a function of the following parameters | |
| # If no custom ID labels were entered, process user-entered multiplication factor. | |
| # Else, count number of ID labels. | |
| if(isTRUE(input$include_Participant_column)) { | |
| if(!isTruthy(input$ID_labels)) { | |
| N = input$multiply_N | |
| } else N = ngram::wordcount(input$ID_labels, sep = ',') | |
| } else N = 1 | |
| # Trials (if selected by user) | |
| if(isTRUE(input$include_Trial_column)) N = N * input$trial_N | |
| # Extra nested factor (if selected by user) | |
| if(isTRUE(input$include_Extra_nested_column)) N = N * input$Extra_nested_N | |
| # Number of between-group conditions (if selected by user) | |
| if(levels_BetweenGroup() > 1) N = N * levels_BetweenGroup() | |
| # Number of within-participant conditions (if selected by user) | |
| if(levels_WithinParticipant() > 1) N = N * levels_WithinParticipant() | |
| N | |
| }) | |
| Participant = reactive({ | |
| # If no custom ID labels are entered... | |
| if(!isTruthy(input$ID_labels)) { | |
| data.frame(Participant = factor(rep(seq(1, final_N())))) | |
| # if any custom ID labels are entered... | |
| } else { | |
| # Place quotes around each factor level | |
| ID_labels = sapply(strsplit(input$ID_labels, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| data.frame(Participant = factor(rep(eval(parse(text = paste0('c(', ID_labels, ')'))), sep = ',', | |
| # Repeat each item as many times as the product below. | |
| # Final_N() divided by number of levels to avoid double | |
| # count, as number of levels is included in Final_N(). | |
| final_N() / ngram::wordcount(input$ID_labels)))) | |
| } | |
| }) | |
| # Trials | |
| Trial = reactive({ | |
| # If Trial column is included by user | |
| if(isTRUE(input$include_Trial_column)) { | |
| data.frame(Trial = factor(rep(seq(1, input$trial_N)))) | |
| # If Trial column is not included by user | |
| } else data.frame(Trial = factor(rep(seq(1, 1)))) | |
| }) | |
| # Extra nested factor | |
| Extra_nested = reactive({ | |
| # If Extra_nested column is included by user | |
| if(isTRUE(input$include_Extra_nested_column)) { | |
| data.frame(Extra_nested = factor(rep(seq(1, input$Extra_nested_N)))) | |
| # If Extra_nested column is not included by user | |
| } else data.frame(Extra_nested = factor(rep(seq(1, 1)))) | |
| }) | |
| # Categorical independent variables | |
| Categorical_Independent1 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent1)) { | |
| set.seed(input$seed) | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Independent1, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Independent1, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Independent1 = sapply(strsplit(input$levels_Categorical_Independent1, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Independent1 = eval(parse(text = paste0('c(', levels_Categorical_Independent1, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Independent1 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Independent2 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent2)) { | |
| set.seed(input$seed * 2) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Independent2, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Independent2, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Independent2 = sapply(strsplit(input$levels_Categorical_Independent2, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Independent2 = eval(parse(text = paste0('c(', levels_Categorical_Independent2, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Independent2 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Independent3 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent3)) { | |
| set.seed(input$seed * 3) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Independent3, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Independent3, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Independent3 = sapply(strsplit(input$levels_Categorical_Independent3, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Independent3 = eval(parse(text = paste0('c(', levels_Categorical_Independent3, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Independent3 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Independent4 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent4)) { | |
| set.seed(input$seed * 4) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Independent4, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Independent4, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Independent4 = sapply(strsplit(input$levels_Categorical_Independent4, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Independent4 = eval(parse(text = paste0('c(', levels_Categorical_Independent4, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Independent4 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Independent5 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent5)) { | |
| set.seed(input$seed * 5) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Independent5, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Independent5, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Independent5 = sapply(strsplit(input$levels_Categorical_Independent5, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Independent5 = eval(parse(text = paste0('c(', levels_Categorical_Independent5, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Independent5 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Independent6 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent6)) { | |
| set.seed(input$seed * 6) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Independent6, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Independent6, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Independent6 = sapply(strsplit(input$levels_Categorical_Independent6, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Independent6 = eval(parse(text = paste0('c(', levels_Categorical_Independent6, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Independent6 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Independent7 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent7)) { | |
| set.seed(input$seed * 7) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Independent7, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Independent7, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Independent7 = sapply(strsplit(input$levels_Categorical_Independent7, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Independent7 = eval(parse(text = paste0('c(', levels_Categorical_Independent7, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Independent7 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Independent8 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Independent8)) { | |
| set.seed(input$seed * 8) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Independent8, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Independent8, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Independent8 = sapply(strsplit(input$levels_Categorical_Independent8, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Independent8 = eval(parse(text = paste0('c(', levels_Categorical_Independent8, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Independent8 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| # Continuous independent variables | |
| Continuous_Independent1 = reactive({ | |
| if(isTruthy(input$name_Continuous_Independent1)) { | |
| set.seed(input$seed * 9) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Independent1_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Independent1_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(1, mean = 1, sd = 1) | |
| }) | |
| Continuous_Independent2 = reactive({ | |
| if(isTruthy(input$name_Continuous_Independent2)) { | |
| set.seed(input$seed * 10) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Independent2_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Independent2_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(1, mean = 1, sd = 1) | |
| }) | |
| Continuous_Independent3 = reactive({ | |
| if(isTruthy(input$name_Continuous_Independent3)) { | |
| set.seed(input$seed * 11) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Independent3_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Independent3_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(1, mean = 1, sd = 1) | |
| }) | |
| Continuous_Independent4 = reactive({ | |
| if(isTruthy(input$name_Continuous_Independent4)) { | |
| set.seed(input$seed * 12) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Independent4_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Independent4_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(1, mean = 1, sd = 1) | |
| }) | |
| Continuous_Independent5 = reactive({ | |
| if(isTruthy(input$name_Continuous_Independent5)) { | |
| set.seed(input$seed * 13) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Independent5_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Independent5_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(1, mean = 1, sd = 1) | |
| }) | |
| Continuous_Independent6 = reactive({ | |
| if(isTruthy(input$name_Continuous_Independent6)) { | |
| set.seed(input$seed * 14) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Independent6_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Independent6_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(1, mean = 1, sd = 1) | |
| }) | |
| Continuous_Independent7 = reactive({ | |
| if(isTruthy(input$name_Continuous_Independent7)) { | |
| set.seed(input$seed * 15) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Independent7_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Independent7_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(1, mean = 1, sd = 1) | |
| }) | |
| Continuous_Independent8 = reactive({ | |
| if(isTruthy(input$name_Continuous_Independent8)) { | |
| set.seed(input$seed * 16) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Independent8_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Independent8_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(1, mean = 1, sd = 1) | |
| }) | |
| # Between-group variables. They are sequentially nested, from the first to the third one. | |
| # Count number of active levels | |
| levels_BetweenGroup1 = reactive({ | |
| if(isTruthy(input$name_BetweenGroup1) & isTruthy(input$BetweenGroup1_Group2)) { | |
| x = sum(c(which(isTruthy(input$BetweenGroup1_Group1)), | |
| which(isTruthy(input$BetweenGroup1_Group2)), | |
| which(isTruthy(input$BetweenGroup1_Group3)), | |
| which(isTruthy(input$BetweenGroup1_Group4)), | |
| which(isTruthy(input$BetweenGroup1_Group5)), | |
| which(isTruthy(input$BetweenGroup1_Group6)), | |
| which(isTruthy(input$BetweenGroup1_Group7)), | |
| which(isTruthy(input$BetweenGroup1_Group8)), | |
| which(isTruthy(input$BetweenGroup1_Group9)), | |
| which(isTruthy(input$BetweenGroup1_Group10)))) | |
| } else x = 1 | |
| }) | |
| levels_BetweenGroup2 = reactive({ | |
| if(isTruthy(input$name_BetweenGroup2) & isTruthy(input$BetweenGroup2_Group2)) { | |
| x = sum(c(which(isTruthy(input$BetweenGroup2_Group1)), | |
| which(isTruthy(input$BetweenGroup2_Group2)), | |
| which(isTruthy(input$BetweenGroup2_Group3)), | |
| which(isTruthy(input$BetweenGroup2_Group4)), | |
| which(isTruthy(input$BetweenGroup2_Group5)), | |
| which(isTruthy(input$BetweenGroup2_Group6)), | |
| which(isTruthy(input$BetweenGroup2_Group7)), | |
| which(isTruthy(input$BetweenGroup2_Group8)), | |
| which(isTruthy(input$BetweenGroup2_Group9)), | |
| which(isTruthy(input$BetweenGroup2_Group10)))) | |
| } else x = 1 | |
| }) | |
| levels_BetweenGroup3 = reactive({ | |
| if(isTruthy(input$name_BetweenGroup3) & isTruthy(input$BetweenGroup3_Group2)) { | |
| x = sum(c(which(isTruthy(input$BetweenGroup3_Group1)), | |
| which(isTruthy(input$BetweenGroup3_Group2)), | |
| which(isTruthy(input$BetweenGroup3_Group3)), | |
| which(isTruthy(input$BetweenGroup3_Group4)), | |
| which(isTruthy(input$BetweenGroup3_Group5)), | |
| which(isTruthy(input$BetweenGroup3_Group6)), | |
| which(isTruthy(input$BetweenGroup3_Group7)), | |
| which(isTruthy(input$BetweenGroup3_Group8)), | |
| which(isTruthy(input$BetweenGroup3_Group9)), | |
| which(isTruthy(input$BetweenGroup3_Group10)))) | |
| } else x = 1 | |
| }) | |
| # Store labels of active levels | |
| BetweenGroup1_labels = reactive({ | |
| BetweenGroup1_labels = paste(input$BetweenGroup1_Group1, input$BetweenGroup1_Group2, input$BetweenGroup1_Group3, | |
| input$BetweenGroup1_Group4, input$BetweenGroup1_Group5, input$BetweenGroup1_Group6, | |
| input$BetweenGroup1_Group7, input$BetweenGroup1_Group8, input$BetweenGroup1_Group9, | |
| input$BetweenGroup1_Group10, sep = ',') %>% | |
| gsub("^,*|(?<=,),|,*$", "", ., perl = TRUE) | |
| # Place quotes around each factor level | |
| BetweenGroup1_labels = sapply(strsplit(BetweenGroup1_labels, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| BetweenGroup1_labels = paste0('c(', BetweenGroup1_labels, ')') | |
| }) | |
| BetweenGroup2_labels = reactive({ | |
| BetweenGroup2_labels = paste(input$BetweenGroup2_Group1, input$BetweenGroup2_Group2, input$BetweenGroup2_Group3, | |
| input$BetweenGroup2_Group4, input$BetweenGroup2_Group5, input$BetweenGroup2_Group6, | |
| input$BetweenGroup2_Group7, input$BetweenGroup2_Group8, input$BetweenGroup2_Group9, | |
| input$BetweenGroup2_Group10, sep = ',') %>% | |
| gsub("^,*|(?<=,),|,*$", "", ., perl = TRUE) | |
| # Place quotes around each factor level | |
| BetweenGroup2_labels = sapply(strsplit(BetweenGroup2_labels, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| BetweenGroup2_labels = paste0('c(', BetweenGroup2_labels, ')') | |
| }) | |
| BetweenGroup3_labels = reactive({ | |
| BetweenGroup3_labels = paste(input$BetweenGroup3_Group1, input$BetweenGroup3_Group2, input$BetweenGroup3_Group3, | |
| input$BetweenGroup3_Group4, input$BetweenGroup3_Group5, input$BetweenGroup3_Group6, | |
| input$BetweenGroup3_Group7, input$BetweenGroup3_Group8, input$BetweenGroup3_Group9, | |
| input$BetweenGroup3_Group10, sep = ',') %>% | |
| gsub("^,*|(?<=,),|,*$", "", ., perl = TRUE) | |
| # Place quotes around each factor level | |
| BetweenGroup3_labels = sapply(strsplit(BetweenGroup3_labels, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| BetweenGroup3_labels = paste0('c(', BetweenGroup3_labels, ')') | |
| }) | |
| # Between-group 1 | |
| BetweenGroup1 = reactive({ | |
| if(isTruthy(input$name_BetweenGroup1)) { | |
| data.frame(BetweenGroup1 = factor(rep(eval(parse(text = paste0(BetweenGroup1_labels()))), | |
| each = 1, final_N() / levels_BetweenGroup1()))) | |
| } else data.frame(BetweenGroup1 = factor(rep(1, final_N()))) | |
| }) | |
| BetweenGroup2 = reactive({ | |
| if(isTruthy(input$name_BetweenGroup2)) { | |
| data.frame(BetweenGroup2 = factor(rep(eval(parse(text = paste0(BetweenGroup2_labels()))), | |
| each = 1, final_N() / levels_BetweenGroup2()))) | |
| } else data.frame(BetweenGroup2 = factor(rep(1, final_N()))) | |
| }) | |
| BetweenGroup3 = reactive({ | |
| if(isTruthy(input$name_BetweenGroup3)) { | |
| data.frame(BetweenGroup3 = factor(rep(eval(parse(text = paste0(BetweenGroup3_labels()))), | |
| each = 1, final_N() / levels_BetweenGroup3()))) | |
| } else data.frame(BetweenGroup3 = factor(rep(1, final_N()))) | |
| }) | |
| # Total | |
| levels_BetweenGroup = reactive({ | |
| if(levels_BetweenGroup1() < 2) { | |
| x = 1 | |
| } | |
| if(levels_BetweenGroup1() > 1) { | |
| x = levels_BetweenGroup1() | |
| } | |
| if(levels_BetweenGroup2() > 1) { | |
| x = x * levels_BetweenGroup2() | |
| } | |
| if(levels_BetweenGroup3() > 1) { | |
| x = x * levels_BetweenGroup3() | |
| } | |
| x | |
| }) | |
| # Within-participant | |
| # Count number of active levels | |
| levels_WithinParticipant1 = reactive({ | |
| if(isTruthy(input$name_WithinParticipant1) & isTruthy(input$WithinParticipant1_Condition2)) { | |
| sum(c(which(isTruthy(input$WithinParticipant1_Condition1)), | |
| which(isTruthy(input$WithinParticipant1_Condition2)), | |
| which(isTruthy(input$WithinParticipant1_Condition3)), | |
| which(isTruthy(input$WithinParticipant1_Condition4)), | |
| which(isTruthy(input$WithinParticipant1_Condition5)), | |
| which(isTruthy(input$WithinParticipant1_Condition6)), | |
| which(isTruthy(input$WithinParticipant1_Condition7)), | |
| which(isTruthy(input$WithinParticipant1_Condition8)), | |
| which(isTruthy(input$WithinParticipant1_Condition9)), | |
| which(isTruthy(input$WithinParticipant1_Condition10)))) | |
| } else 1 | |
| }) | |
| levels_WithinParticipant2 = reactive({ | |
| if(isTruthy(input$name_WithinParticipant2) & isTruthy(input$WithinParticipant2_Condition2)) { | |
| sum(c(which(isTruthy(input$WithinParticipant2_Condition1)), | |
| which(isTruthy(input$WithinParticipant2_Condition2)), | |
| which(isTruthy(input$WithinParticipant2_Condition3)), | |
| which(isTruthy(input$WithinParticipant2_Condition4)), | |
| which(isTruthy(input$WithinParticipant2_Condition5)), | |
| which(isTruthy(input$WithinParticipant2_Condition6)), | |
| which(isTruthy(input$WithinParticipant2_Condition7)), | |
| which(isTruthy(input$WithinParticipant2_Condition8)), | |
| which(isTruthy(input$WithinParticipant2_Condition9)), | |
| which(isTruthy(input$WithinParticipant2_Condition10)))) | |
| } else 1 | |
| }) | |
| levels_WithinParticipant3 = reactive({ | |
| if(isTruthy(input$name_WithinParticipant3) & isTruthy(input$WithinParticipant3_Condition2)) { | |
| sum(c(which(isTruthy(input$WithinParticipant3_Condition1)), | |
| which(isTruthy(input$WithinParticipant3_Condition2)), | |
| which(isTruthy(input$WithinParticipant3_Condition3)), | |
| which(isTruthy(input$WithinParticipant3_Condition4)), | |
| which(isTruthy(input$WithinParticipant3_Condition5)), | |
| which(isTruthy(input$WithinParticipant3_Condition6)), | |
| which(isTruthy(input$WithinParticipant3_Condition7)), | |
| which(isTruthy(input$WithinParticipant3_Condition8)), | |
| which(isTruthy(input$WithinParticipant3_Condition9)), | |
| which(isTruthy(input$WithinParticipant3_Condition10)))) | |
| } else 1 | |
| }) | |
| # Total | |
| levels_WithinParticipant = reactive({ | |
| if(levels_WithinParticipant1() < 2) { | |
| x = 1 | |
| } | |
| if(levels_WithinParticipant1() > 1) { | |
| x = levels_WithinParticipant1() | |
| } | |
| if(levels_WithinParticipant2() > 1) { | |
| x = x * levels_WithinParticipant2() | |
| } | |
| if(levels_WithinParticipant3() > 1) { | |
| x = x * levels_WithinParticipant3() | |
| } | |
| x | |
| }) | |
| WithinParticipant1 = reactive({ | |
| if(isTruthy(input$name_WithinParticipant1)) { | |
| data.frame(WithinParticipant1 = rep(c(input$WithinParticipant1_Condition1, input$WithinParticipant1_Condition2, | |
| input$WithinParticipant1_Condition3, input$WithinParticipant1_Condition4, | |
| input$WithinParticipant1_Condition5, input$WithinParticipant1_Condition6, | |
| input$WithinParticipant1_Condition7, input$WithinParticipant1_Condition8, | |
| input$WithinParticipant1_Condition9, input$WithinParticipant1_Condition10), | |
| # Repeat each condition a number of times according to the number of conditions | |
| # in the other variables | |
| each = ifelse(levels_WithinParticipant2() > 1 & levels_WithinParticipant3() > 1, | |
| levels_WithinParticipant2() * levels_WithinParticipant3(), | |
| ifelse(levels_WithinParticipant2() > 1 & levels_WithinParticipant3() < 2, | |
| levels_WithinParticipant2(), 1)), | |
| final_N())) %>% | |
| mutate_all(~ifelse(. %in% c(''), NA, .)) %>% na.omit() | |
| } else data.frame(WithinParticipant1 = factor(rep(1, final_N()))) | |
| }) | |
| WithinParticipant2 = reactive({ | |
| if(isTruthy(input$name_WithinParticipant2)) { | |
| data.frame(WithinParticipant2 = rep(c(input$WithinParticipant2_Condition1, input$WithinParticipant2_Condition2, | |
| input$WithinParticipant2_Condition3, input$WithinParticipant2_Condition4, | |
| input$WithinParticipant2_Condition5, input$WithinParticipant2_Condition6, | |
| input$WithinParticipant2_Condition7, input$WithinParticipant2_Condition8, | |
| input$WithinParticipant2_Condition9, input$WithinParticipant2_Condition10), | |
| # Repeat each condition a number of times according to the number of conditions | |
| # in the other variables | |
| each = ifelse(levels_WithinParticipant1() > 1 & levels_WithinParticipant3() > 1, | |
| levels_WithinParticipant1() * levels_WithinParticipant3(), | |
| ifelse(levels_WithinParticipant1() > 1 & levels_WithinParticipant3() < 2, | |
| levels_WithinParticipant1(), 1)), | |
| final_N())) %>% | |
| mutate_all(~ifelse(. %in% c(''), NA, .)) %>% na.omit() | |
| } else data.frame(WithinParticipant2 = factor(rep(1, final_N()))) | |
| }) | |
| WithinParticipant3 = reactive({ | |
| if(isTruthy(input$name_WithinParticipant3)) { | |
| data.frame(WithinParticipant3 = rep(c(input$WithinParticipant3_Condition1, input$WithinParticipant3_Condition2, | |
| input$WithinParticipant3_Condition3, input$WithinParticipant3_Condition4, | |
| input$WithinParticipant3_Condition5, input$WithinParticipant3_Condition6, | |
| input$WithinParticipant3_Condition7, input$WithinParticipant3_Condition8, | |
| input$WithinParticipant3_Condition9, input$WithinParticipant3_Condition10), | |
| # Repeat each condition a number of times according to the number of conditions | |
| # in the other variables | |
| each = ifelse(levels_WithinParticipant1() > 1 & levels_WithinParticipant2() > 1, | |
| levels_WithinParticipant1() * levels_WithinParticipant2(), | |
| ifelse(levels_WithinParticipant1() > 1 & levels_WithinParticipant2() < 2, | |
| levels_WithinParticipant1(), 1)), | |
| final_N())) %>% | |
| mutate_all(~ifelse(. %in% c(''), NA, .)) %>% na.omit() | |
| } else data.frame(WithinParticipant3 = factor(rep(1, final_N()))) | |
| }) | |
| # Categorical dependent variables | |
| Categorical_Dependent1 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent1)) { | |
| set.seed(input$seed * 17) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Dependent1, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Dependent1, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Dependent1 = sapply(strsplit(input$levels_Categorical_Dependent1, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Dependent1 = eval(parse(text = paste0('c(', levels_Categorical_Dependent1, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Dependent1 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Dependent2 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent2)) { | |
| set.seed(input$seed * 18) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Dependent2, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Dependent2, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Dependent2 = sapply(strsplit(input$levels_Categorical_Dependent2, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Dependent2 = eval(parse(text = paste0('c(', levels_Categorical_Dependent2, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Dependent2 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Dependent3 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent3)) { | |
| set.seed(input$seed * 19) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Dependent3, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Dependent3, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Dependent3 = sapply(strsplit(input$levels_Categorical_Dependent3, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Dependent3 = eval(parse(text = paste0('c(', levels_Categorical_Dependent3, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Dependent3 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Dependent4 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent4)) { | |
| set.seed(input$seed * 20) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Dependent4, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Dependent4, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Dependent4 = sapply(strsplit(input$levels_Categorical_Dependent4, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Dependent4 = eval(parse(text = paste0('c(', levels_Categorical_Dependent4, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Dependent4 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Dependent5 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent5)) { | |
| set.seed(input$seed * 21) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Dependent5, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Dependent5, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Dependent5 = sapply(strsplit(input$levels_Categorical_Dependent5, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Dependent5 = eval(parse(text = paste0('c(', levels_Categorical_Dependent5, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Dependent5 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Dependent6 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent6)) { | |
| set.seed(input$seed * 22) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Dependent6, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Dependent6, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Dependent6 = sapply(strsplit(input$levels_Categorical_Dependent6, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Dependent6 = eval(parse(text = paste0('c(', levels_Categorical_Dependent6, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Dependent6 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Dependent7 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent7)) { | |
| set.seed(input$seed * 23) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Dependent7, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Dependent7, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Dependent7 = sapply(strsplit(input$levels_Categorical_Dependent7, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Dependent7 = eval(parse(text = paste0('c(', levels_Categorical_Dependent7, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Dependent7 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| Categorical_Dependent8 = reactive({ | |
| if(isTruthy(input$probability_Categorical_Dependent8)) { | |
| set.seed(input$seed * 24) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rbinom(final_N(), | |
| # Below, count number of levels. One unit has to be subtracted from the word count to make rbinom() accurate. | |
| ngram::wordcount(input$levels_Categorical_Dependent8, sep = ',') - 1, | |
| eval(parse(text = paste0('c(', input$probability_Categorical_Dependent8, ')')))) | |
| # Place quotes around each factor level | |
| levels_Categorical_Dependent8 = sapply(strsplit(input$levels_Categorical_Dependent8, ',+'), function(x) toString(dQuote(x, FALSE))) | |
| # Wrap levels in c() | |
| levels_Categorical_Dependent8 = eval(parse(text = paste0('c(', levels_Categorical_Dependent8, ')'))) | |
| x = as.factor(x) | |
| levels(x) = levels_Categorical_Dependent8 | |
| x | |
| } else rbinom(final_N(), 1, 1) | |
| }) | |
| # Continuous dependent variables | |
| Continuous_Dependent1 = reactive({ | |
| if(isTruthy(input$name_Continuous_Dependent1)) { | |
| set.seed(input$seed * 25) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Dependent1_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Dependent1_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(final_N(), mean = 1, sd = 1) %>% round(digits = input$rounding) | |
| }) | |
| Continuous_Dependent2 = reactive({ | |
| if(isTruthy(input$name_Continuous_Dependent2)) { | |
| set.seed(input$seed * 26) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Dependent2_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Dependent2_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(final_N(), mean = 1, sd = 1) %>% round(digits = input$rounding) | |
| }) | |
| Continuous_Dependent3 = reactive({ | |
| if(isTruthy(input$name_Continuous_Dependent3)) { | |
| set.seed(input$seed * 27) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Dependent3_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Dependent3_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(final_N(), mean = 1, sd = 1) %>% round(digits = input$rounding) | |
| }) | |
| Continuous_Dependent4 = reactive({ | |
| if(isTruthy(input$name_Continuous_Dependent4)) { | |
| set.seed(input$seed * 28) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Dependent4_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Dependent4_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(final_N(), mean = 1, sd = 1) %>% round(digits = input$rounding) | |
| }) | |
| Continuous_Dependent5 = reactive({ | |
| if(isTruthy(input$name_Continuous_Dependent5)) { | |
| set.seed(input$seed * 29) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Dependent5_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Dependent5_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(final_N(), mean = 1, sd = 1) %>% round(digits = input$rounding) | |
| }) | |
| Continuous_Dependent6 = reactive({ | |
| if(isTruthy(input$name_Continuous_Dependent6)) { | |
| set.seed(input$seed * 30) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Dependent6_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Dependent6_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(final_N(), mean = 1, sd = 1) %>% round(digits = input$rounding) | |
| }) | |
| Continuous_Dependent7 = reactive({ | |
| if(isTruthy(input$name_Continuous_Dependent7)) { | |
| set.seed(input$seed * 31) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Dependent7_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Dependent7_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(final_N(), mean = 1, sd = 1) %>% round(digits = input$rounding) | |
| }) | |
| Continuous_Dependent8 = reactive({ | |
| if(isTruthy(input$name_Continuous_Dependent8)) { | |
| set.seed(input$seed * 32) # For explanation about this multiplication, see 'Important notes about the seed', above. | |
| x = rnorm(final_N(), | |
| mean = eval(parse(text = paste0('c(', input$Continuous_Dependent8_mean, ')'))), | |
| sd = eval(parse(text = paste0('c(', input$Continuous_Dependent8_SD, ')')))) %>% round(digits = input$rounding) | |
| } else x = rnorm(final_N(), mean = 1, sd = 1) %>% round(digits = input$rounding) | |
| }) | |
| # Final data set | |
| dataset = reactive({ | |
| # General, initial structure | |
| df = data.frame( | |
| Participant(), | |
| BetweenGroup1(), BetweenGroup2(), BetweenGroup3(), | |
| WithinParticipant1(), WithinParticipant2(), WithinParticipant3(), | |
| Trial(), Extra_nested() | |
| ) %>% | |
| # Create repeated rows for the within-participant repeated measures | |
| expand( | |
| nesting( | |
| Participant(), | |
| Categorical_Independent1(), | |
| Categorical_Independent2(), | |
| Categorical_Independent3(), | |
| Categorical_Independent4(), | |
| Categorical_Independent5(), | |
| Categorical_Independent6(), | |
| Categorical_Independent7(), | |
| Categorical_Independent8(), | |
| Continuous_Independent1 = Continuous_Independent1(), | |
| Continuous_Independent2 = Continuous_Independent2(), | |
| Continuous_Independent3 = Continuous_Independent3(), | |
| Continuous_Independent4 = Continuous_Independent4(), | |
| Continuous_Independent5 = Continuous_Independent5(), | |
| Continuous_Independent6 = Continuous_Independent6(), | |
| Continuous_Independent7 = Continuous_Independent7(), | |
| Continuous_Independent8 = Continuous_Independent8(), | |
| BetweenGroup1(), BetweenGroup2(), BetweenGroup3() | |
| ), | |
| WithinParticipant1(), WithinParticipant2(), WithinParticipant3(), | |
| Trial(), Extra_nested(), | |
| ) %>% | |
| cbind(Categorical_Dependent1(), | |
| Categorical_Dependent2(), | |
| Categorical_Dependent3(), | |
| Categorical_Dependent4(), | |
| Categorical_Dependent5(), | |
| Categorical_Dependent6(), | |
| Categorical_Dependent7(), | |
| Categorical_Dependent8(), | |
| Continuous_Dependent1 = Continuous_Dependent1(), | |
| Continuous_Dependent2 = Continuous_Dependent2(), | |
| Continuous_Dependent3 = Continuous_Dependent3(), | |
| Continuous_Dependent4 = Continuous_Dependent4(), | |
| Continuous_Dependent5 = Continuous_Dependent5(), | |
| Continuous_Dependent6 = Continuous_Dependent6(), | |
| Continuous_Dependent7 = Continuous_Dependent7(), | |
| Continuous_Dependent8 = Continuous_Dependent8()) | |
| # Having created a general structure, remove variables that haven't been filled in by user | |
| # and name each variable with the user's choice | |
| # Within-participant variables (placed first because they crucially require repeating other variables) | |
| if(isTruthy(input$name_WithinParticipant3)) { | |
| df = df %>% select_if(is.numeric) %>% | |
| aggregate(by = list(Participant = df$Participant, | |
| Categorical_Independent1 = df$Categorical_Independent1, | |
| Categorical_Independent2 = df$Categorical_Independent2, | |
| Categorical_Independent3 = df$Categorical_Independent3, | |
| Categorical_Independent4 = df$Categorical_Independent4, | |
| Categorical_Independent5 = df$Categorical_Independent5, | |
| Categorical_Independent6 = df$Categorical_Independent6, | |
| Categorical_Independent7 = df$Categorical_Independent7, | |
| Categorical_Independent8 = df$Categorical_Independent8, | |
| BetweenGroup1 = df$BetweenGroup1, BetweenGroup2 = df$BetweenGroup2, | |
| BetweenGroup3 = df$BetweenGroup3, | |
| WithinParticipant1 = df$WithinParticipant1, WithinParticipant2 = df$WithinParticipant2, | |
| WithinParticipant3 = df$WithinParticipant3, | |
| Trial = df$Trial, Extra_nested = df$Extra_nested, | |
| Categorical_Dependent1 = df$Categorical_Dependent1, | |
| Categorical_Dependent2 = df$Categorical_Dependent2, | |
| Categorical_Dependent3 = df$Categorical_Dependent3, | |
| Categorical_Dependent4 = df$Categorical_Dependent4, | |
| Categorical_Dependent5 = df$Categorical_Dependent5, | |
| Categorical_Dependent6 = df$Categorical_Dependent6, | |
| Categorical_Dependent7 = df$Categorical_Dependent7, | |
| Categorical_Dependent8 = df$Categorical_Dependent8), | |
| FUN = mean) | |
| } | |
| if(isTruthy(input$name_WithinParticipant2) & !isTruthy(input$name_WithinParticipant3)) { | |
| df = df %>% select(-WithinParticipant3) %>% select_if(is.numeric) %>% | |
| aggregate(by = list(Participant = df$Participant, | |
| Categorical_Independent1 = df$Categorical_Independent1, | |
| Categorical_Independent2 = df$Categorical_Independent2, | |
| Categorical_Independent3 = df$Categorical_Independent3, | |
| Categorical_Independent4 = df$Categorical_Independent4, | |
| Categorical_Independent5 = df$Categorical_Independent5, | |
| Categorical_Independent6 = df$Categorical_Independent6, | |
| Categorical_Independent7 = df$Categorical_Independent7, | |
| Categorical_Independent8 = df$Categorical_Independent8, | |
| BetweenGroup1 = df$BetweenGroup1, BetweenGroup2 = df$BetweenGroup2, | |
| BetweenGroup3 = df$BetweenGroup3, | |
| WithinParticipant1 = df$WithinParticipant1, WithinParticipant2 = df$WithinParticipant2, | |
| Trial = df$Trial, Extra_nested = df$Extra_nested, | |
| Categorical_Dependent1 = df$Categorical_Dependent1, | |
| Categorical_Dependent2 = df$Categorical_Dependent2, | |
| Categorical_Dependent3 = df$Categorical_Dependent3, | |
| Categorical_Dependent4 = df$Categorical_Dependent4, | |
| Categorical_Dependent5 = df$Categorical_Dependent5, | |
| Categorical_Dependent6 = df$Categorical_Dependent6, | |
| Categorical_Dependent7 = df$Categorical_Dependent7, | |
| Categorical_Dependent8 = df$Categorical_Dependent8), | |
| FUN = mean) | |
| } | |
| if(isTruthy(input$name_WithinParticipant1) & !isTruthy(input$name_WithinParticipant2)) { | |
| df = df %>% select(-c(WithinParticipant2, WithinParticipant3)) %>% select_if(is.numeric) %>% | |
| aggregate(by = list(Participant = df$Participant, | |
| Categorical_Independent1 = df$Categorical_Independent1, | |
| Categorical_Independent2 = df$Categorical_Independent2, | |
| Categorical_Independent3 = df$Categorical_Independent3, | |
| Categorical_Independent4 = df$Categorical_Independent4, | |
| Categorical_Independent5 = df$Categorical_Independent5, | |
| Categorical_Independent6 = df$Categorical_Independent6, | |
| Categorical_Independent7 = df$Categorical_Independent7, | |
| Categorical_Independent8 = df$Categorical_Independent8, | |
| BetweenGroup1 = df$BetweenGroup1, BetweenGroup2 = df$BetweenGroup2, | |
| BetweenGroup3 = df$BetweenGroup3, | |
| WithinParticipant1 = df$WithinParticipant1, | |
| Trial = df$Trial, Extra_nested = df$Extra_nested, | |
| Categorical_Dependent1 = df$Categorical_Dependent1, | |
| Categorical_Dependent2 = df$Categorical_Dependent2, | |
| Categorical_Dependent3 = df$Categorical_Dependent3, | |
| Categorical_Dependent4 = df$Categorical_Dependent4, | |
| Categorical_Dependent5 = df$Categorical_Dependent5, | |
| Categorical_Dependent6 = df$Categorical_Dependent6, | |
| Categorical_Dependent7 = df$Categorical_Dependent7, | |
| Categorical_Dependent8 = df$Categorical_Dependent8), | |
| FUN = mean) | |
| } | |
| if(!isTruthy(input$name_WithinParticipant1)) { | |
| df = df %>% select(-c(WithinParticipant1, WithinParticipant2, WithinParticipant3)) %>% select_if(is.numeric) %>% | |
| aggregate(by = list(Participant = df$Participant, | |
| Categorical_Independent1 = df$Categorical_Independent1, | |
| Categorical_Independent2 = df$Categorical_Independent2, | |
| Categorical_Independent3 = df$Categorical_Independent3, | |
| Categorical_Independent4 = df$Categorical_Independent4, | |
| Categorical_Independent5 = df$Categorical_Independent5, | |
| Categorical_Independent6 = df$Categorical_Independent6, | |
| Categorical_Independent7 = df$Categorical_Independent7, | |
| Categorical_Independent8 = df$Categorical_Independent8, | |
| BetweenGroup1 = df$BetweenGroup1, BetweenGroup2 = df$BetweenGroup2, | |
| BetweenGroup3 = df$BetweenGroup3, | |
| Trial = df$Trial, Extra_nested = df$Extra_nested, | |
| Categorical_Dependent1 = df$Categorical_Dependent1, | |
| Categorical_Dependent2 = df$Categorical_Dependent2, | |
| Categorical_Dependent3 = df$Categorical_Dependent3, | |
| Categorical_Dependent4 = df$Categorical_Dependent4, | |
| Categorical_Dependent5 = df$Categorical_Dependent5, | |
| Categorical_Dependent6 = df$Categorical_Dependent6, | |
| Categorical_Dependent7 = df$Categorical_Dependent7, | |
| Categorical_Dependent8 = df$Categorical_Dependent8), | |
| FUN = mean) | |
| } | |
| # Between-group variables | |
| if(isTruthy(input$name_BetweenGroup2) & !isTruthy(input$name_BetweenGroup3)) { | |
| df = df %>% select(-any_of(c('BetweenGroup3', 'BetweenGroup3()'))) | |
| } | |
| if(isTruthy(input$name_BetweenGroup1) & !isTruthy(input$name_BetweenGroup2)) { | |
| df = df %>% select(-any_of(c('BetweenGroup3', 'BetweenGroup3()', | |
| 'BetweenGroup2', 'BetweenGroup2()'))) | |
| } | |
| if(!isTruthy(input$name_BetweenGroup1)) { | |
| df = df %>% select(-any_of(c('BetweenGroup3', 'BetweenGroup3()', | |
| 'BetweenGroup2', 'BetweenGroup2()', | |
| 'BetweenGroup1', 'BetweenGroup1()'))) | |
| } | |
| # Categorical independent variables | |
| if(!isTruthy(input$name_Categorical_Independent8)) { | |
| df = df %>% select(-any_of(c('Categorical_Independent8', 'Categorical_Independent8()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Independent7)) { | |
| df = df %>% select(-any_of(c('Categorical_Independent8', 'Categorical_Independent8()', | |
| 'Categorical_Independent7', 'Categorical_Independent7()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Independent6)) { | |
| df = df %>% select(-any_of(c('Categorical_Independent8', 'Categorical_Independent8()', | |
| 'Categorical_Independent7', 'Categorical_Independent7()', | |
| 'Categorical_Independent6', 'Categorical_Independent6()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Independent5)) { | |
| df = df %>% select(-any_of(c('Categorical_Independent8', 'Categorical_Independent8()', | |
| 'Categorical_Independent7', 'Categorical_Independent7()', | |
| 'Categorical_Independent6', 'Categorical_Independent6()', | |
| 'Categorical_Independent5', 'Categorical_Independent5()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Independent4)) { | |
| df = df %>% select(-any_of(c('Categorical_Independent8', 'Categorical_Independent8()', | |
| 'Categorical_Independent7', 'Categorical_Independent7()', | |
| 'Categorical_Independent6', 'Categorical_Independent6()', | |
| 'Categorical_Independent5', 'Categorical_Independent5()', | |
| 'Categorical_Independent4', 'Categorical_Independent4()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Independent3)) { | |
| df = df %>% select(-any_of(c('Categorical_Independent8', 'Categorical_Independent8()', | |
| 'Categorical_Independent7', 'Categorical_Independent7()', | |
| 'Categorical_Independent6', 'Categorical_Independent6()', | |
| 'Categorical_Independent5', 'Categorical_Independent5()', | |
| 'Categorical_Independent4', 'Categorical_Independent4()', | |
| 'Categorical_Independent3', 'Categorical_Independent3()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Independent2)) { | |
| df = df %>% select(-any_of(c('Categorical_Independent8', 'Categorical_Independent8()', | |
| 'Categorical_Independent7', 'Categorical_Independent7()', | |
| 'Categorical_Independent6', 'Categorical_Independent6()', | |
| 'Categorical_Independent5', 'Categorical_Independent5()', | |
| 'Categorical_Independent4', 'Categorical_Independent4()', | |
| 'Categorical_Independent3', 'Categorical_Independent3()', | |
| 'Categorical_Independent2', 'Categorical_Independent2()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Independent1)) { | |
| df = df %>% select(-any_of(c('Categorical_Independent8', 'Categorical_Independent8()', | |
| 'Categorical_Independent7', 'Categorical_Independent7()', | |
| 'Categorical_Independent6', 'Categorical_Independent6()', | |
| 'Categorical_Independent5', 'Categorical_Independent5()', | |
| 'Categorical_Independent4', 'Categorical_Independent4()', | |
| 'Categorical_Independent3', 'Categorical_Independent3()', | |
| 'Categorical_Independent2', 'Categorical_Independent2()', | |
| 'Categorical_Independent1', 'Categorical_Independent1()'))) | |
| } | |
| # Continuous independent variables | |
| if(!isTruthy(input$name_Continuous_Independent8)) { | |
| df = df %>% select(-c(Continuous_Independent8)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Independent7)) { | |
| df = df %>% select(-c(Continuous_Independent7)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Independent6)) { | |
| df = df %>% select(-c(Continuous_Independent6)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Independent5)) { | |
| df = df %>% select(-c(Continuous_Independent5)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Independent4)) { | |
| df = df %>% select(-c(Continuous_Independent4)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Independent3)) { | |
| df = df %>% select(-c(Continuous_Independent3)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Independent2)) { | |
| df = df %>% select(-c(Continuous_Independent2)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Independent1)) { | |
| df = df %>% select(-c(Continuous_Independent1)) | |
| } | |
| # Categorical dependent variables | |
| if(!isTruthy(input$name_Categorical_Dependent8)) { | |
| df = df %>% select(-any_of(c('Categorical_Dependent8', 'Categorical_Dependent8()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Dependent7)) { | |
| df = df %>% select(-any_of(c('Categorical_Dependent7', 'Categorical_Dependent7()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Dependent6)) { | |
| df = df %>% select(-any_of(c('Categorical_Dependent6', 'Categorical_Dependent6()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Dependent5)) { | |
| df = df %>% select(-any_of(c('Categorical_Dependent5', 'Categorical_Dependent5()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Dependent4)) { | |
| df = df %>% select(-any_of(c('Categorical_Dependent4', 'Categorical_Dependent4()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Dependent3)) { | |
| df = df %>% select(-any_of(c('Categorical_Dependent3', 'Categorical_Dependent3()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Dependent2)) { | |
| df = df %>% select(-any_of(c('Categorical_Dependent2', 'Categorical_Dependent2()'))) | |
| } | |
| if(!isTruthy(input$name_Categorical_Dependent1)) { | |
| df = df %>% select(-any_of(c('Categorical_Dependent1', 'Categorical_Dependent1()'))) | |
| } | |
| # Continuous dependent variables | |
| if(!isTruthy(input$name_Continuous_Dependent8)) { | |
| df = df %>% select(-c(Continuous_Dependent8)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Dependent7)) { | |
| df = df %>% select(-c(Continuous_Dependent7)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Dependent6)) { | |
| df = df %>% select(-c(Continuous_Dependent6)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Dependent5)) { | |
| df = df %>% select(-c(Continuous_Dependent5)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Dependent4)) { | |
| df = df %>% select(-c(Continuous_Dependent4)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Dependent3)) { | |
| df = df %>% select(-c(Continuous_Dependent3)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Dependent2)) { | |
| df = df %>% select(-c(Continuous_Dependent2)) | |
| } | |
| if(!isTruthy(input$name_Continuous_Dependent1)) { | |
| df = df %>% select(-c(Continuous_Dependent1)) | |
| } | |
| # Participant | |
| if(isFALSE(input$include_Participant_column)) df = df %>% select(-Participant) | |
| # Trial | |
| if(isFALSE(input$include_Trial_column)) df = df %>% select(-Trial) | |
| # Extra nested variable | |
| if(isFALSE(input$include_Extra_nested_column)) df = df %>% select(-Extra_nested) | |
| # Remove columns with duplicate names | |
| df %>% subset(., select = which(!duplicated(names(.)))) | |
| }) | |
| ``` | |
| Sample (*N* = `r reactive(try(if(isTRUE(input$include_Participant_column)){final_N()}, silent = TRUE) %>% gsub("\\Error.*", "", .))`) {#sample style="background-color: #FEFEFE; data-width: 100%; width: 900px; margin: 0 auto;"} | |
| ======================================================================= | |
| Column {style='margin-top:30px'} | |
| --- | |
| ### <span style='font-size:18px; color:#4D4F54; font-weight:bold;'> Parameters of the sample</span> | |
| <div style = "padding-top: 20px; padding-right: 60px; padding-bottom: 100px; padding-left: 60px; background-color: #FEFEFE; font-size: 16px; line-height: 1.6;"> | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'name_Participant_column', 'Name of the base ID column', value = 'Participant') | |
| checkboxInput('include_Participant_column', 'Include this column (un/check)', value = TRUE) | |
| ``` | |
| <h3 style='padding-top: 5px; color:#2C6367'> Current sample size (*N*) = `r reactive(final_N())` </h3> | |
| Adjust *N* by changing the multiplication factor below (see updated number above). Note that large samples may incur some processing time. | |
| ```{r} | |
| numericInput('multiply_N', NULL, 3, min = 1, width = '170px') | |
| ``` | |
| Replace this column with names/categories (comma-separated). Delete to revert to a numeric variable. | |
| ```{r} | |
| textAreaInput(height = '45px', resize = 'vertical', 'ID_labels', NULL, | |
| placeholder = "E.g., people's names, cities, treatments, etc.", width = '500px') | |
| ``` | |
| <br> | |
| ### Code details | |
| The sample size is interlocked with the factorial structure of the data set. That is, if any groups are created in the Groups tab, participants will be evenly drawn from the total *N* (in contrast, groups created in the *Individual* tab distribute the number of participants as the user indicates in the *Probability* field). For any within-participant factors, repeated measures are created by expanding the number of rows in the long-format data set ([last tab](#data-set)). | |
| </div> | |
| Summary | |
| ======================================================================= | |
| Inputs {.sidebar style='max-width: 600px; overflow: scroll; overflow-y: hidden; height: 100%; width: 250px; position: fixed; z-index: 1; top: 0; left: 0; background-color: #F4FBF4; padding-top: 50px; padding-right: 10px; padding-left: 30px;'} | |
| ----------------------------------------------------------------------- | |
| ### {.no-title} | |
| <div style = 'padding-top: 20px; padding-right: 5px; padding-bottom: 10px;'> | |
| A custom summary of the data set can be constructed by entering specific variables in the fields below. | |
| ```{r} | |
| # Include/exclude number of observations | |
| checkboxInput('include_n', 'Include number of observations (n)', value = TRUE) | |
| # Preselect categorical variables other than Participants and some large, nested factors such as Trials | |
| selected_categorical = | |
| reactive({ | |
| final_dataset() %>% select(-any_of(c(input$name_Participant_column, | |
| input$name_Trial_column, | |
| input$name_Extra_nested_column))) %>% | |
| select_if(~is.factor(.) | is.character(.)) %>% names() | |
| }) | |
| renderUI({ | |
| selectizeInput('categorical_variables', 'Categorical variables', multiple = TRUE, | |
| choices = final_dataset() %>% select_if(~is.factor(.) | is.character(.)) %>% names(), | |
| selected = selected_categorical()) | |
| }) | |
| renderUI({ | |
| selectizeInput('continuous_variables', 'Numeric variables', multiple = TRUE, | |
| choices = final_dataset() %>% select_if(is.numeric) %>% names(), | |
| selected = final_dataset() %>% select_if(is.numeric) %>% names()) | |
| }) | |
| ``` | |
| ##### Descriptives for numeric variables | |
| ```{r} | |
| # Selecting numeric descriptives | |
| checkboxInput('include_Minimum', 'Minimum', value = FALSE) | |
| checkboxInput('include_Maximum', 'Maximum', value = FALSE) | |
| checkboxInput('include_Median', 'Median', value = FALSE) | |
| checkboxInput('include_Mean', 'Mean', value = TRUE) | |
| checkboxInput('include_SD', 'SD', value = TRUE) | |
| # Create text string compiling selected numeric descriptives | |
| numeric_descriptives = | |
| reactive({ | |
| x = 'Minimum = min, Maximum = max, Median = median, Mean = mean, SD = sd' | |
| # If Minimum unchecked, remove it | |
| if(isFALSE(input$include_Minimum)) x = str_remove(x, 'Minimum = min, ') | |
| # If Maximum unchecked, remove it | |
| if(isFALSE(input$include_Maximum)) x = str_remove(x, 'Maximum = max, ') | |
| # If Median unchecked, remove it | |
| if(isFALSE(input$include_Median)) x = str_remove(x, 'Median = median, ') | |
| # If Mean unchecked, remove it | |
| if(isFALSE(input$include_Mean)) x = str_remove(x, 'Mean = mean, ') | |
| # If SD unchecked, remove it | |
| if(isFALSE(input$include_SD)) x = str_remove(x, ', SD = sd') %>% str_remove('SD = sd') | |
| x | |
| }) | |
| ``` | |
| </div> | |
| Summary {style="margin-top:30px"} | |
| ----------------------------------------------------------------------- | |
| ### {.no-title} | |
| <div style = 'padding-right: 10px; background-color: white;'> | |
| ```{r} | |
| custom_summary = | |
| reactive({ | |
| # If any grouping factors are selected | |
| if(isTruthy(input$categorical_variables)) { | |
| # This first bit displays number of observations per cell ('n') | |
| summary = final_dataset() %>% | |
| group_by(across(any_of(input$categorical_variables))) %>% tally %>% | |
| # Merge the previous basic structure with the columns that are relevant now | |
| merge( | |
| final_dataset() %>% | |
| group_by(across(any_of(input$categorical_variables))) %>% | |
| summarise(across(any_of(input$continuous_variables), | |
| eval(parse(text = paste0('list(', numeric_descriptives(), ')'))))) %>% | |
| # Round off numeric variables | |
| mutate(across(where(is.numeric), round, input$rounding)) | |
| ) | |
| # If no grouping variables are selected | |
| } else { | |
| summary = final_dataset() %>% | |
| summarise(across(any_of(input$continuous_variables), | |
| eval(parse(text = paste0('list(', numeric_descriptives(), ')'))))) %>% | |
| # Round off numeric variables | |
| mutate(across(where(is.numeric), round, input$rounding)) | |
| } | |
| # Conditionally hide number-of-observations column (n), if chosen | |
| if(isFALSE(input$include_n)) summary = summary %>% select(-n) | |
| summary | |
| }) | |
| renderDT( | |
| datatable(custom_summary(), | |
| rownames = FALSE, extensions = c('Buttons'), class="nowrap compact cell-border", selection = 'none', | |
| options = list(order = list(0, 'asc'), dom = 'Bifrt', pageLength = nrow(custom_summary()), scroller = TRUE, | |
| buttons = list(list(extend = 'csv', text = HTML('<i class="fas fa-download" aria-hidden="true"></i> Click to download summary (.csv)'), | |
| filename = paste0('Custom summary of simulated data - retrieved on ', | |
| str_replace_all(format(Sys.time(), '%d %b %Y at %X %Z'), ':', '.'), | |
| " (find info in Pablo Bernabeu's GitHub repository Experimental-data-simulation)")))) | |
| ) | |
| ) | |
| ``` | |
| </div> | |
| Data set <i class="fas fa-flag-checkered" aria-hidden="true"></i> | |
| ======================================================================= | |
| Column {style="margin-top:20px; padding-top:10px; position:static; min-width: 580px; max-width: 580px; min-height: 1000px;"} | |
| ----------------------------------------------------------------------- | |
| ### <span style='font-size:18px; color:#4D4F54;'> Parameters to ensure reproducibility of the simulated data </span> {style='max-height: 70px;'} | |
| ```{r} | |
| # Save parameter list | |
| parameters = reactive({ | |
| parameters = paste0('\n\nParameters for the reproducibility of the simulated data\n', | |
| '--------------------------------------------------------------\n', | |
| 'Please consider these parameters along with the data set.\n', | |
| 'Information and web application available at:\n', | |
| 'https://github.com/pablobernabeu/Experimental-data-simulation/\n', | |
| '- Reference -\n', | |
| 'Bernabeu, P., & Lynott, D. (2020). Web application for the\n', | |
| 'simulation of experimental data (Version ', sprintf("%.1f", app_version), ').\n', | |
| 'https://github.com/pablobernabeu/Experimental-data-simulation/\n', | |
| '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n', | |
| '-- Home tab --\n', | |
| '\nNumber of decimal places (rounding) = ', input$rounding, '\n', | |
| 'Seed number = ', input$seed, '\n') | |
| if(isTruthy(input$name_BetweenGroup1)) { | |
| parameters = paste0(parameters, | |
| '\n-- Groups tab --\n', | |
| '\nBetween-group factor 1: ', input$name_BetweenGroup1, | |
| '\nLevels: ', | |
| paste(input$BetweenGroup1_Group1, input$BetweenGroup1_Group2, input$BetweenGroup1_Group3, | |
| input$BetweenGroup1_Group4, input$BetweenGroup1_Group5, input$BetweenGroup1_Group6, | |
| input$BetweenGroup1_Group7, input$BetweenGroup1_Group8, input$BetweenGroup1_Group9, | |
| input$BetweenGroup1_Group10, sep = ', ') %>% | |
| gsub("^,*|(?<=,) ,|,* $", "", ., perl = TRUE) %>% gsub(",$", "", ., perl = TRUE), | |
| '\n') | |
| } | |
| if(isTruthy(input$name_BetweenGroup2)) { | |
| parameters = paste0(parameters, | |
| '\nBetween-group factor 2: ', input$name_BetweenGroup2, | |
| '\nLevels: ', | |
| paste(input$BetweenGroup2_Group1, input$BetweenGroup2_Group2, input$BetweenGroup2_Group3, | |
| input$BetweenGroup2_Group4, input$BetweenGroup2_Group5, input$BetweenGroup2_Group6, | |
| input$BetweenGroup2_Group7, input$BetweenGroup2_Group8, input$BetweenGroup2_Group9, | |
| input$BetweenGroup2_Group10, sep = ', ') %>% | |
| gsub("^,*|(?<=,) ,|,* $", "", ., perl = TRUE) %>% gsub(",$", "", ., perl = TRUE), | |
| '\n') | |
| } | |
| if(isTruthy(input$name_BetweenGroup3)) { | |
| parameters = paste0(parameters, | |
| '\nBetween-group factor 3: ', input$name_BetweenGroup3, | |
| '\nLevels: ', | |
| paste(input$BetweenGroup3_Group1, input$BetweenGroup3_Group2, input$BetweenGroup3_Group3, | |
| input$BetweenGroup3_Group4, input$BetweenGroup3_Group5, input$BetweenGroup3_Group6, | |
| input$BetweenGroup3_Group7, input$BetweenGroup3_Group8, input$BetweenGroup3_Group9, | |
| input$BetweenGroup3_Group10, sep = ', ') %>% | |
| gsub("^,*|(?<=,) ,|,* $", "", ., perl = TRUE) %>% gsub(",$", "", ., perl = TRUE), | |
| '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Independent1)) { | |
| parameters = paste0(parameters, | |
| '\n-- Individual tab --\n', | |
| '\nCategorical independent variable 1: ', input$name_Categorical_Independent1, | |
| '\nLevels: ', input$levels_Categorical_Independent1, '\nProbability [0, 1] (per group): ', | |
| input$probability_Categorical_Independent1, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Independent2)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical independent variable 2: ', input$name_Categorical_Independent2, | |
| '\nLevels: ', input$levels_Categorical_Independent2, '\nProbability [0, 1] (per group): ', | |
| input$probability_Categorical_Independent2, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Independent3)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical independent variable 3: ', input$name_Categorical_Independent3, | |
| '\nLevels: ', input$levels_Categorical_Independent3, '\nProbability [0, 1] (per group): ', | |
| input$probability_Categorical_Independent3, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Independent4)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical independent variable 4: ', input$name_Categorical_Independent4, | |
| '\nLevels: ', input$levels_Categorical_Independent4, '\nProbability [0, 1] (per group): ', | |
| input$probability_Categorical_Independent4, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Independent5)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical independent variable 5: ', input$name_Categorical_Independent5, | |
| '\nLevels: ', input$levels_Categorical_Independent5, '\nProbability [0, 1] (per group): ', | |
| input$probability_Categorical_Independent5, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Independent6)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical independent variable 6: ', input$name_Categorical_Independent6, | |
| '\nLevels: ', input$levels_Categorical_Independent6, '\nProbability [0, 1] (per group): ', | |
| input$probability_Categorical_Independent6, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Independent7)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical independent variable 7: ', input$name_Categorical_Independent7, | |
| '\nLevels: ', input$levels_Categorical_Independent7, '\nProbability [0, 1] (per group): ', | |
| input$probability_Categorical_Independent7, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Independent8)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical independent variable 8: ', input$name_Categorical_Independent8, | |
| '\nLevels: ', input$levels_Categorical_Independent8, '\nProbability [0, 1] (per group): ', | |
| input$probability_Categorical_Independent8, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Independent1)) { | |
| parameters = paste0(parameters, | |
| '\n-- Individual tab --\n', | |
| '\nContinuous independent variable 1: ', input$name_Continuous_Independent1, | |
| '\nMean (per group): ', input$Continuous_Independent1_mean, | |
| '\nSD (per group): ', input$Continuous_Independent1_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Independent2)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous independent variable 2: ', input$name_Continuous_Independent2, | |
| '\nMean (per group): ', input$Continuous_Independent2_mean, | |
| '\nSD (per group): ', input$Continuous_Independent2_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Independent3)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous independent variable 3: ', input$name_Continuous_Independent3, | |
| '\nMean (per group): ', input$Continuous_Independent3_mean, | |
| '\nSD (per group): ', input$Continuous_Independent3_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Independent4)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous independent variable 4: ', input$name_Continuous_Independent4, | |
| '\nMean (per group): ', input$Continuous_Independent4_mean, | |
| '\nSD (per group): ', input$Continuous_Independent4_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Independent5)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous independent variable 5: ', input$name_Continuous_Independent5, | |
| '\nMean (per group): ', input$Continuous_Independent5_mean, | |
| '\nSD (per group): ', input$Continuous_Independent5_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Independent6)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous independent variable 6: ', input$name_Continuous_Independent6, | |
| '\nMean (per group): ', input$Continuous_Independent6_mean, | |
| '\nSD (per group): ', input$Continuous_Independent6_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Independent7)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous independent variable 7: ', input$name_Continuous_Independent7, | |
| '\nMean (per group): ', input$Continuous_Independent7_mean, | |
| '\nSD (per group): ', input$Continuous_Independent7_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Independent8)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous independent variable 8: ', input$name_Continuous_Independent8, | |
| '\nMean (per group): ', input$Continuous_Independent8_mean, | |
| '\nSD (per group): ', input$Continuous_Independent8_SD, '\n') | |
| } | |
| if(isTruthy(input$name_WithinParticipant1)) { | |
| parameters = paste0(parameters, | |
| '\n-- Conditions tab --\n', | |
| '\nWithin-participant factor 1: ', input$name_WithinParticipant1, | |
| '\nLevels: ', | |
| paste(input$WithinParticipant1_Condition1, input$WithinParticipant1_Condition2, input$WithinParticipant1_Condition3, | |
| input$WithinParticipant1_Condition4, input$WithinParticipant1_Condition5, input$WithinParticipant1_Condition6, | |
| input$WithinParticipant1_Condition7, input$WithinParticipant1_Condition8, input$WithinParticipant1_Condition9, | |
| input$WithinParticipant1_Condition10, sep = ', ') %>% | |
| gsub("^,*|(?<=,) ,|,* $", "", ., perl = TRUE) %>% gsub(",$", "", ., perl = TRUE), | |
| '\n') | |
| } | |
| if(isTruthy(input$name_WithinParticipant2)) { | |
| parameters = paste0(parameters, | |
| '\nWithin-participant factor 2: ', input$name_WithinParticipant2, | |
| '\nLevels: ', | |
| paste(input$WithinParticipant2_Condition1, input$WithinParticipant2_Condition2, input$WithinParticipant2_Condition3, | |
| input$WithinParticipant2_Condition4, input$WithinParticipant2_Condition5, input$WithinParticipant2_Condition6, | |
| input$WithinParticipant2_Condition7, input$WithinParticipant2_Condition8, input$WithinParticipant2_Condition9, | |
| input$WithinParticipant2_Condition10, sep = ', ') %>% | |
| gsub("^,*|(?<=,) ,|,* $", "", ., perl = TRUE) %>% gsub(",$", "", ., perl = TRUE), | |
| '\n') | |
| } | |
| if(isTruthy(input$name_WithinParticipant3)) { | |
| parameters = paste0(parameters, | |
| '\nWithin-participant factor 3: ', input$name_WithinParticipant3, | |
| '\nLevels: ', | |
| paste(input$WithinParticipant3_Condition1, input$WithinParticipant3_Condition2, input$WithinParticipant3_Condition3, | |
| input$WithinParticipant3_Condition4, input$WithinParticipant3_Condition5, input$WithinParticipant3_Condition6, | |
| input$WithinParticipant3_Condition7, input$WithinParticipant3_Condition8, input$WithinParticipant3_Condition9, | |
| input$WithinParticipant3_Condition10, sep = ', ') %>% | |
| gsub("^,*|(?<=,) ,|,* $", "", ., perl = TRUE) %>% gsub(",$", "", ., perl = TRUE), | |
| '\n') | |
| } | |
| if(isTRUE(input$include_Participant_column)) { | |
| parameters = paste0(parameters, | |
| '\n-- Sample tab --\n', | |
| '\nBase ID column name: ', input$name_Participant_column, | |
| '\nMultiplication factor = ', input$multiply_N, | |
| '\n') | |
| } else parameters = paste0(parameters, '\n- Sample tab -\nBase ID column: removed by unchecking the box\n') | |
| if(isTRUE(input$include_Trial_column)) { | |
| parameters = paste0(parameters, | |
| '\n-- Nested tab --\n', | |
| '\nExtra nested factor 1: included by checking the box', | |
| '\nName: ', input$name_Trial_column, | |
| '\nNumber of levels = ', input$trial_N, | |
| '\n') | |
| } | |
| if(isTRUE(input$include_Extra_nested_column)) { | |
| parameters = paste0(parameters, | |
| '\nExtra nested factor 2: included by checking the box', | |
| '\nName: ', input$name_Extra_nested_column, | |
| '\nNumber of levels = ', input$Extra_nested_N, | |
| '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent1)) { | |
| parameters = paste0(parameters, | |
| '\n-- Dependent tab --\n', | |
| '\nCategorical dependent variable 1: ', input$name_Categorical_Dependent1, | |
| '\nLevels: ', input$levels_Categorical_Dependent1, '\nProbability [0, 1] (per cell): ', | |
| input$probability_Categorical_Dependent1, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent2)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical dependent variable 2: ', input$name_Categorical_Dependent2, | |
| '\nLevels: ', input$levels_Categorical_Dependent2, '\nProbability [0, 1] (per cell): ', | |
| input$probability_Categorical_Dependent2, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent3)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical dependent variable 3: ', input$name_Categorical_Dependent3, | |
| '\nLevels: ', input$levels_Categorical_Dependent3, '\nProbability [0, 1] (per cell): ', | |
| input$probability_Categorical_Dependent3, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent4)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical dependent variable 4: ', input$name_Categorical_Dependent4, | |
| '\nLevels: ', input$levels_Categorical_Dependent4, '\nProbability [0, 1] (per cell): ', | |
| input$probability_Categorical_Dependent4, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent5)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical dependent variable 5: ', input$name_Categorical_Dependent5, | |
| '\nLevels: ', input$levels_Categorical_Dependent5, '\nProbability [0, 1] (per cell): ', | |
| input$probability_Categorical_Dependent5, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent6)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical dependent variable 6: ', input$name_Categorical_Dependent6, | |
| '\nLevels: ', input$levels_Categorical_Dependent6, '\nProbability [0, 1] (per cell): ', | |
| input$probability_Categorical_Dependent6, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent7)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical dependent variable 7: ', input$name_Categorical_Dependent7, | |
| '\nLevels: ', input$levels_Categorical_Dependent7, '\nProbability [0, 1] (per cell): ', | |
| input$probability_Categorical_Dependent7, '\n') | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent8)) { | |
| parameters = paste0(parameters, | |
| '\nCategorical dependent variable 8: ', input$name_Categorical_Dependent8, | |
| '\nLevels: ', input$levels_Categorical_Dependent8, '\nProbability [0, 1] (per cell): ', | |
| input$probability_Categorical_Dependent8, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent1)) { | |
| parameters = paste0(parameters, | |
| '\n-- Dependent tab --\n', | |
| '\nContinuous dependent variable 1: ', input$name_Continuous_Dependent1, | |
| '\nMean (per cell): ', input$Continuous_Dependent1_mean, | |
| '\nSD (per cell): ', input$Continuous_Dependent1_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent2)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous dependent variable 2: ', input$name_Continuous_Dependent2, | |
| '\nMean (per cell): ', input$Continuous_Dependent2_mean, | |
| '\nSD (per cell): ', input$Continuous_Dependent2_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent3)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous dependent variable 3: ', input$name_Continuous_Dependent3, | |
| '\nMean (per cell): ', input$Continuous_Dependent3_mean, | |
| '\nSD (per cell): ', input$Continuous_Dependent3_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent4)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous dependent variable 4: ', input$name_Continuous_Dependent4, | |
| '\nMean (per cell): ', input$Continuous_Dependent4_mean, | |
| '\nSD (per cell): ', input$Continuous_Dependent4_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent5)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous dependent variable 5: ', input$name_Continuous_Dependent5, | |
| '\nMean (per cell): ', input$Continuous_Dependent5_mean, | |
| '\nSD (per cell): ', input$Continuous_Dependent5_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent6)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous dependent variable 6: ', input$name_Continuous_Dependent6, | |
| '\nMean (per cell): ', input$Continuous_Dependent6_mean, | |
| '\nSD (per cell): ', input$Continuous_Dependent6_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent7)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous dependent variable 7: ', input$name_Continuous_Dependent7, | |
| '\nMean (per cell): ', input$Continuous_Dependent7_mean, | |
| '\nSD (per cell): ', input$Continuous_Dependent7_SD, '\n') | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent8)) { | |
| parameters = paste0(parameters, | |
| '\nContinuous dependent variable 8: ', input$name_Continuous_Dependent8, | |
| '\nMean (per cell): ', input$Continuous_Dependent8_mean, | |
| '\nSD (per cell): ', input$Continuous_Dependent8_SD, '\n') | |
| } | |
| parameters = paste0(parameters, | |
| '\n\nResulting data set\n', | |
| '------------------------------------------------------------\n', | |
| 'Below are some properties of the data set, resulting from\n', | |
| 'user-entered parameters and automatic computations.\n', | |
| '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n' | |
| ) | |
| if(isTRUE(input$include_Participant_column)) { | |
| parameters = paste0(parameters, | |
| 'N (', input$name_Participant_column, ') = ', final_N(), | |
| "\n^ Automatically based on number of factor levels\n", | |
| "times the multiplication factor shown above.\n\n") | |
| } | |
| # Print parameters | |
| paste0(parameters, | |
| 'Number of rows = ', nrow(final_dataset()), '\n', | |
| 'Number of columns = ', length(final_dataset()), '\n', | |
| 'Number of cells (rows times columns) = ', nrow(final_dataset()) * length(final_dataset()), | |
| '\n\n\n') | |
| }) | |
| # Enable download of parameter list | |
| # Create the actual downloadLink | |
| output$parameters_download_link = renderUI({ | |
| downloadLink('parameters_download', HTML('<i class="fas fa-download" aria-hidden="true"></i> Click to download'), | |
| style = 'border-bottom:none !important; text-decoration: none !important; font-weight: normal !important;', | |
| class = 'button-parameters-download') | |
| }) | |
| # Add download handling | |
| output$parameters_download = downloadHandler( | |
| filename = function() { | |
| paste0('Parameter list retrieved on ', | |
| str_replace_all(format(Sys.time(), '%d %b %Y at %X %Z'), ':', '.'), | |
| " (find info in Pablo Bernabeu's GitHub repository Experimental-data-simulation).txt") | |
| }, | |
| content = function(file) { cat(parameters(), file = file) } | |
| ) | |
| # Show link | |
| uiOutput('parameters_download_link') | |
| ``` | |
| ### {.no-title style="height:500px;"} | |
| ```{r} | |
| # Show parameter list | |
| reactive(cat(parameters())) | |
| ``` | |
| Column {style='margin-top:20px; padding-top:10px; data-width: 100%; position: static; height: 1000px;'} | |
| ----------------------------------------------------------------------- | |
| ### {.no-title} | |
| ```{r} | |
| final_dataset = reactive({ | |
| final = dataset() %>% | |
| # Tally factor levels to cross them and keep the right number of cases | |
| group_by(across(any_of( | |
| dataset() %>% select_if(~is.factor(.) | is.character(.)) %>% names() | |
| ))) | |
| # Select the columns that are especially relevant now | |
| selected_columns = | |
| dataset() %>% | |
| group_by(across(where(~is.factor(.) | is.character(.)))) | |
| # Merge | |
| final = merge(final, selected_columns) | |
| # Order columns in standard order, which is important for the setting of parameters within factor levels | |
| final %>% | |
| select(any_of(c( | |
| input$name_Participant_column, | |
| input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3, | |
| input$name_Categorical_Independent1, input$name_Categorical_Independent2, | |
| input$name_Categorical_Independent3, input$name_Categorical_Independent4, | |
| input$name_Categorical_Independent5, input$name_Categorical_Independent6, | |
| input$name_Categorical_Independent7, input$name_Categorical_Independent8, | |
| input$name_Continuous_Independent1, input$name_Continuous_Independent2, | |
| input$name_Continuous_Independent3, input$name_Continuous_Independent4, | |
| input$name_Continuous_Independent5, input$name_Continuous_Independent6, | |
| input$name_Continuous_Independent7, input$name_Continuous_Independent8, | |
| input$name_WithinParticipant1, input$name_WithinParticipant2, input$name_WithinParticipant3, | |
| input$name_Trial_column, input$name_Extra_nested_column, | |
| input$name_Categorical_Dependent1, input$name_Categorical_Dependent2, | |
| input$name_Categorical_Dependent3, input$name_Categorical_Dependent4, | |
| input$name_Categorical_Dependent5, input$name_Categorical_Dependent6, | |
| input$name_Categorical_Dependent7, input$name_Categorical_Dependent8, | |
| input$name_Continuous_Dependent1, input$name_Continuous_Dependent2, | |
| input$name_Continuous_Dependent3, input$name_Continuous_Dependent4, | |
| input$name_Continuous_Dependent5, input$name_Continuous_Dependent6, | |
| input$name_Continuous_Dependent7, input$name_Continuous_Dependent8 | |
| ))) | |
| # Rename columns | |
| if(isTruthy(input$name_Categorical_Independent1)) { | |
| names(final)[names(final)=="Categorical_Independent1"] = input$name_Categorical_Independent1 | |
| } | |
| if(isTruthy(input$name_Categorical_Independent2)) { | |
| names(final)[names(final)=="Categorical_Independent2"] = input$name_Categorical_Independent2 | |
| } | |
| if(isTruthy(input$name_Categorical_Independent3)) { | |
| names(final)[names(final)=="Categorical_Independent3"] = input$name_Categorical_Independent3 | |
| } | |
| if(isTruthy(input$name_Categorical_Independent4)) { | |
| names(final)[names(final)=="Categorical_Independent4"] = input$name_Categorical_Independent4 | |
| } | |
| if(isTruthy(input$name_Categorical_Independent5)) { | |
| names(final)[names(final)=="Categorical_Independent5"] = input$name_Categorical_Independent5 | |
| } | |
| if(isTruthy(input$name_Categorical_Independent6)) { | |
| names(final)[names(final)=="Categorical_Independent6"] = input$name_Categorical_Independent6 | |
| } | |
| if(isTruthy(input$name_Categorical_Independent7)) { | |
| names(final)[names(final)=="Categorical_Independent7"] = input$name_Categorical_Independent7 | |
| } | |
| if(isTruthy(input$name_Categorical_Independent8)) { | |
| names(final)[names(final)=="Categorical_Independent8"] = input$name_Categorical_Independent8 | |
| } | |
| if(isTruthy(input$name_Continuous_Independent1)) { | |
| names(final)[names(final)=="Continuous_Independent1"] = input$name_Continuous_Independent1 | |
| } | |
| if(isTruthy(input$name_Continuous_Independent2)) { | |
| names(final)[names(final)=="Continuous_Independent2"] = input$name_Continuous_Independent2 | |
| } | |
| if(isTruthy(input$name_Continuous_Independent3)) { | |
| names(final)[names(final)=="Continuous_Independent3"] = input$name_Continuous_Independent3 | |
| } | |
| if(isTruthy(input$name_Continuous_Independent4)) { | |
| names(final)[names(final)=="Continuous_Independent4"] = input$name_Continuous_Independent4 | |
| } | |
| if(isTruthy(input$name_Continuous_Independent5)) { | |
| names(final)[names(final)=="Continuous_Independent5"] = input$name_Continuous_Independent5 | |
| } | |
| if(isTruthy(input$name_Continuous_Independent6)) { | |
| names(final)[names(final)=="Continuous_Independent6"] = input$name_Continuous_Independent6 | |
| } | |
| if(isTruthy(input$name_Continuous_Independent7)) { | |
| names(final)[names(final)=="Continuous_Independent7"] = input$name_Continuous_Independent7 | |
| } | |
| if(isTruthy(input$name_Continuous_Independent8)) { | |
| names(final)[names(final)=="Continuous_Independent8"] = input$name_Continuous_Independent8 | |
| } | |
| if(isTruthy(input$name_BetweenGroup1)) { | |
| names(final)[names(final)=="BetweenGroup1"] = input$name_BetweenGroup1 | |
| } | |
| if(isTruthy(input$name_BetweenGroup2)) { | |
| names(final)[names(final)=="BetweenGroup2"] = input$name_BetweenGroup2 | |
| } | |
| if(isTruthy(input$name_BetweenGroup3)) { | |
| names(final)[names(final)=="BetweenGroup3"] = input$name_BetweenGroup3 | |
| } | |
| if(isTruthy(input$name_WithinParticipant1)) { | |
| names(final)[names(final)=="WithinParticipant1"] = input$name_WithinParticipant1 | |
| } | |
| if(isTruthy(input$name_WithinParticipant2)) { | |
| names(final)[names(final)=="WithinParticipant2"] = input$name_WithinParticipant2 | |
| } | |
| if(isTruthy(input$name_WithinParticipant3)) { | |
| names(final)[names(final)=="WithinParticipant3"] = input$name_WithinParticipant3 | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent1)) { | |
| names(final)[names(final)=="Continuous_Dependent1"] = input$name_Continuous_Dependent1 | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent2)) { | |
| names(final)[names(final)=="Continuous_Dependent2"] = input$name_Continuous_Dependent2 | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent3)) { | |
| names(final)[names(final)=="Continuous_Dependent3"] = input$name_Continuous_Dependent3 | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent4)) { | |
| names(final)[names(final)=="Continuous_Dependent4"] = input$name_Continuous_Dependent4 | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent5)) { | |
| names(final)[names(final)=="Continuous_Dependent5"] = input$name_Continuous_Dependent5 | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent6)) { | |
| names(final)[names(final)=="Continuous_Dependent6"] = input$name_Continuous_Dependent6 | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent7)) { | |
| names(final)[names(final)=="Continuous_Dependent7"] = input$name_Continuous_Dependent7 | |
| } | |
| if(isTruthy(input$name_Continuous_Dependent8)) { | |
| names(final)[names(final)=="Continuous_Dependent8"] = input$name_Continuous_Dependent8 | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent1)) { | |
| names(final)[names(final)=="Categorical_Dependent1"] = input$name_Categorical_Dependent1 | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent2)) { | |
| names(final)[names(final)=="Categorical_Dependent2"] = input$name_Categorical_Dependent2 | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent3)) { | |
| names(final)[names(final)=="Categorical_Dependent3"] = input$name_Categorical_Dependent3 | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent4)) { | |
| names(final)[names(final)=="Categorical_Dependent4"] = input$name_Categorical_Dependent4 | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent5)) { | |
| names(final)[names(final)=="Categorical_Dependent5"] = input$name_Categorical_Dependent5 | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent6)) { | |
| names(final)[names(final)=="Categorical_Dependent6"] = input$name_Categorical_Dependent6 | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent7)) { | |
| names(final)[names(final)=="Categorical_Dependent7"] = input$name_Categorical_Dependent7 | |
| } | |
| if(isTruthy(input$name_Categorical_Dependent8)) { | |
| names(final)[names(final)=="Categorical_Dependent8"] = input$name_Categorical_Dependent8 | |
| } | |
| if(isTRUE(input$include_Participant_column)) { | |
| names(final)[names(final)=="Participant"] = input$name_Participant_column | |
| } | |
| if(isTRUE(input$include_Trial_column)) { | |
| names(final)[names(final)=="Trial"] = input$name_Trial_column | |
| } | |
| if(isTRUE(input$include_Extra_nested_column)) { | |
| names(final)[names(final)=="Extra_nested"] = input$name_Extra_nested_column | |
| } | |
| final | |
| }) | |
| renderDT( | |
| datatable(final_dataset(), | |
| rownames = FALSE, extensions = c('Buttons'), class="nowrap compact cell-border", selection = 'none', | |
| options = list(order = list(0, 'asc'), dom = 'Bifrt', pageLength = nrow(final_dataset()), scroller = TRUE, | |
| buttons = list(list(extend = 'csv', text = HTML('<i class="fas fa-download" aria-hidden="true"></i> Click to download data set (.csv)'), | |
| filename = paste0('Data simulation using seed number ', input$seed, ', retrieved on ', | |
| str_replace_all(format(Sys.time(), '%d %b %Y at %X %Z'), ':', '.'), | |
| " (find info in Pablo Bernabeu's GitHub repository Experimental-data-simulation)")))) | |
| ) | |
| ) | |
| ``` | |