<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/rshiny-for-clinical-trials-simple-randomization-tables/"></div></div><div><a data-url="http://www.r-bloggers.com/rshiny-for-clinical-trials-simple-randomization-tables/" data-counturl="http://www.r-bloggers.com/rshiny-for-clinical-trials-simple-randomization-tables/" data-count="horizontal" data-text="R/Shiny for clinical trials: simple randomization tables" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://talesofr.wordpress.com/2016/06/09/rshiny-for-simple-randomization-tables/"> R – Tales of R</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>One of the things I most like from <a target="_blank" href="https://www.r-project.org/">R</a> + <a target="_blank" href="http://shiny.rstudio.com/">Shiny</a> is that it enables me to serve the power and flexibility of R in small “chunks” to cover different needs, allowing people not used to R to benefit from it. However, what I like most is that’s really fun and easy to program those utilities for a person without any specific programming background.</p>
<p>Here’s a small hack done in R/Shiny: it covered an urgent need for a study involving patient randomisation to two branches of treatment, in what is commonly known as a <em>clinical trial</em>. This task posed some challenges:</p>
<ul>
<li>First, this trial was not financed in any way (at least initially). It was a small, independent study comparing two approved techniques, so the sponsor had to avoid expensive software or services.</li>
<li>Another reason for software customization is that treatment groups were partially ‘blind’: for people who assessed effectiveness and… also for statistical analysis (treatment administration was <em>open-label</em>). This means that the person in charge of data analysis must know which group is assigned to a patient, but doesn’t know <strong>what treatment is assigned to either group</strong>.</li>
</ul>
<p>To tackle the points above, my app should have two main features:</p>
<ul>
<li>The sponsor (here, a medical doctor) must be able to effectively control study blindness and also provide emergency blind disclosure. This control should extend to data analysis to minimize bias favoring either treatment.</li>
<li>R has tools to create random samples, but the MD in charge of the study sponsoring doesn’t know how to use R. We needed a friendly interface for random table creation.</li>
</ul>
<p>Here’s how I got it to work:</p>
<ul>
<li>The very core of this Shiny app is a combination between the <strong><a target="_blank" href="https://stat.ethz.ch/R-manual/R-devel/library/base/html/Random.html">set.seed</a></strong> and <strong><a target="_blank" href="https://stat.ethz.ch/R-manual/R-devel/library/base/html/sample.html">sample</a></strong> R functions. The PIN number (the <strong>set.seed</strong> argument) works like a secret passcode that links to a given random table. E.g., every time I enter ‘5432’, the random tables will look the same. This protects from accidental blindness disclosure, as nobody can find the correct random table without the proper PIN, <em>even if they can access the app’s source code</em>.</li>
<li>The tables are created column by column, ordered at first. Then we proceed to randomize (via the <strong>sample</strong> function) both the treatment column (in the random table) and the Group column (in the PIN table).</li>
<li>Once the tables are created they can be downloaded as .CSV files, printed, signed and dated to document the randomization procedure. The app’s open source code and the PIN number will provide reproducibility to the procedure for many years.</li>
</ul>
<p>Unfortunately I wasn’t able to insert <strong>iframes</strong> to embed the app, so I posted a screenshot:</p>
<p> </p>
<p><img height="581" alt="Random table generator for clinical trials" width="878" class="wp-image-761" src="https://talesofr.files.wordpress.com/2016/06/random_gen.png?w=878&h=581"></p>
<p>The app is far from perfect, but it covers the basic needs for the trial. You can test it here:</p>
<p><a target="_blank" href="http://aurora.shinyapps.io/random_gen">http://aurora.shinyapps.io/random_gen</a></p>
<p>And the GitHub repo is available here.</p>
<p><a target="_blank" rel="nofollow" href="https://github.com/aurora-mareviv/random_gen">https://github.com/aurora-mareviv/random_gen</a></p>
<p><a target="_blank" rel="nofollow" href="https://github.com/aurora-mareviv/random_gen/blob/master/server.R">https://github.com/aurora-mareviv/random_gen/blob/master/server.R</a></p>
<p><a target="_blank" rel="nofollow" href="https://github.com/aurora-mareviv/random_gen/blob/master/ui.R">https://github.com/aurora-mareviv/random_gen/blob/master/ui.R</a></p>
<p>Feel free to use/ adapt/ fork it to your needs!</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/talesofr.wordpress.com/701/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/talesofr.wordpress.com/701/" border="0"></a> <img height="1" alt="" width="1" src="https://pixel.wp.com/b.gif?host=talesofr.wordpress.com&blog=51185123&%23038;post=701&%23038;subd=talesofr&%23038;ref=&%23038;feed=1" border="0"></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/rshiny-for-clinical-trials-simple-randomization-tables/"></div></div><div><a data-url="http://www.r-bloggers.com/rshiny-for-clinical-trials-simple-randomization-tables/" data-counturl="http://www.r-bloggers.com/rshiny-for-clinical-trials-simple-randomization-tables/" data-count="vertical" data-text="R/Shiny for clinical trials: simple randomization tables" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://talesofr.wordpress.com/2016/06/09/rshiny-for-simple-randomization-tables/"> R – Tales of R</a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/xvMy_OqS0tc"></a></div>