This repository contains R functions to facilitate work at the Sheffield Clinical Trials Research Unit (CTRU), part of the School of Health and Related Research (ScHARR) at The University of Sheffield. The intention is to share code between colleagues so that common repetitive tasks become trivial and we do not spend time solving the same problems.
Readers may also find the following slides useful. They are written by the author of this package and contain a host of examples and links to additional resoures on using R in a reproducible workflow...
If all you want to do is use these functions then its pretty straight-forward to install them thanks to the devtools
package. Install it from CRAN and then install this repository from GitHub...
install.packages('devtools')
devtools::install_github('ns-ctru/ctru')
## And of course load the library
library(ctru)
You can now use the functions read_prospect()
, fields_prospect()
and so forth.
The package now includes a Shiny application (i.e. interactive Web page) that allows the calculation of sample sizes using a number of different R packages. A helper function is included so that once you have installed and loaded the library (as describved above) you can start the application using...
ctru_shiny()
Read more about the included Shiny applications below.
To collaborate in this work you will need to install Git on your computer and have a GitHub account. If you're not familiar with either of these you may find the tutorial Conversational Git a useful place to start. The GitHub help pages are also excellent.
Once you've got a GitHub account you need to fork the ns-ctru/ctru
repository, clone your fork to your computer to work on it, make changes/addition and push them back to your fork then make a make pull requests.
I would advocate using SSH Keys with your GitHub account to make it easy to push updates without having to enter your password every single time.
read_prospect()
Lookups.csv
to convert all factor variables to the correct encoding.event_name
converted to factor internally (may require inclusion of event_name
in Lookups.csv
that is exported from Prospect).recruitment()
table_summary()
...
.plot_summary()
facet_grid()
them with rows for surveys and columns for the specified groups.idm_lsoa()
eq5d_score()
consort()
diagram
package (further examples here).regress_ctru()
relevel()
)for each factor variable in a model (something akin to the way texreg()
handles things).binomial
.texreg()
but stargazer()
is a more flexible tabulating option.Shiny applications are included in this packages (currently n = 1). A helper function (ctru_shiny()
) is included to start the different applications. It includes the option to specify the display.mode
which can be useful if you wish to look at the source code in the application (use the option display.mode = "showcase"
if so).
A WebUI to a number of R packages which will calculate sample sizes and/or power for the specified parameters. . To start it run...
ctru_shiny(example = 'sample_size')
A few links to other resources that people might find useful...
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.