Title: | Example RStudio Project Templates |
---|---|
Description: | Templates and functions for use in CTU Bern. |
Authors: | Alan G. Haynes |
Maintainer: | Alan G. Haynes <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.6.1 |
Built: | 2025-02-27 14:22:48 UTC |
Source: | https://github.com/CTU-Bern/CTUtemplate |
Insert CTU standard header to the active document This function is not intended to be used in any scripts.
add_ctu_header()
add_ctu_header()
adds CTU header to the active document
Colour specific text in a html document
coloured_text(colour, ...)
coloured_text(colour, ...)
colour |
colour to use for the content |
... |
content to be coloured |
In quarto/Rmarkdown documents, use the function in an inline R chunk
(`r coloured_text(...)`
) or in an R chunk with the result set to asis
coloured_text("red", "This text should be red") # also works with multiple contents coloured_text("red", "This text should be red", "this one too") # For multiple colours, use multiple calls to the function: coloured_text("red", "this is red,") coloured_text("blue", "and this is blue!")
coloured_text("red", "This text should be red") # also works with multiple contents coloured_text("red", "This text should be red", "this one too") # For multiple colours, use multiple calls to the function: coloured_text("red", "this is red,") coloured_text("blue", "and this is blue!")
Calculates sample size or power for single-stage trials with a binary endpoint according to: Ahern, R. P., Sample size tables for exact single-stage phase II designs. Statistics in medicine 20.6 (2001): 859-866.
OneStageSS(p0, p1, power = 0.8, n = NA, alpha = 0.05, nstart = 1)
OneStageSS(p0, p1, power = 0.8, n = NA, alpha = 0.05, nstart = 1)
p0 |
Proportion of events under H0 |
p1 |
Proportion of events under H1 |
power |
Power, default=0.8 |
n |
Sample size, calculated if NA, otherwise power is calculated |
alpha |
Alpha, default=0.05 |
nstart |
Number of patients to start iterations, default=1, can be increased to save time |
List with number of patients with events for a significant trial (r), number of patients (n), alpha and power.
# Calculate sample size OneStageSS(p0=0.5,p1=0.6,alpha=0.05,power=0.8) # Calculate power OneStageSS(p0=0.5,p1=0.6,alpha=0.05,n=100)
# Calculate sample size OneStageSS(p0=0.5,p1=0.6,alpha=0.05,power=0.8) # Calculate power OneStageSS(p0=0.5,p1=0.6,alpha=0.05,n=100)
This is not intended to be run manually... rather via knitting a document
report_pdf( report_template = find_resource("report", "report.tex"), latex_engine = "pdflatex", ... )
report_pdf( report_template = find_resource("report", "report.tex"), latex_engine = "pdflatex", ... )
report_template |
tex template to use |
latex_engine |
tex engine to use (pdflatex, lualatex, xelatex) |
... |
options passed to bookdown |
unibeCols
package has all of the UNIBE colours.UNIBE red
Get the official UNIBE red colour. Note that the unibeCols
package has all of the UNIBE colours.
unibeRed(alpha = 1)
unibeRed(alpha = 1)
alpha |
alpha for transparency (0 to 1) |
hexidecimal colour code
[unibeCols::unibeRed()]
plot(1:5, col = unibeRed())
plot(1:5, col = unibeRed())
Parameterized reports allow to create reports in a loop. Examples might be site specific quality reports or recruitment reports.
use_param_report_template(save_as, open = TRUE, ...)
use_param_report_template(save_as, open = TRUE, ...)
save_as |
filename to save the files as (do not include extension as multiple files are created) |
open |
logical indicating whether to open the file |
... |
other arguments passed to |
This function creates 2 files as a barebones template for such parameterized
reports. An Rmd file is created (based on the UNIBE template) and an R file
containing a small loop. Currently, the you have to supervise this loop, as
use_ubreportclo
(which relies on usethis::use_template
) will
not overwrite files without being given explicit permission.
saves two files, an Rmd and an R file
# use_param_report_template("param")
# use_param_report_template("param")
Use the CTU quarto html template This function will download and optionally open the quarto markdown (qmd) file and the other necessary files from github.
Use the CTU quarto revealjs presentation template This function will download and optionally open the quarto markdown (qmd) file and the other necessary files from github.
Use the CTU quarto html recruitment report template This function will download and optionally open the quarto markdown (qmd) file and the other necessary files from github.
Use the CTU quarto html sample size report template This function will download and optionally open the quarto markdown (qmd) file and the other necessary files from github.
Use the CTU quarto typst template This function will download and optionally open the quarto markdown (qmd) file and the other necessary files from github.
use_qmd_html(save_in = ".", open = TRUE) use_qmd_pres(save_in = ".", open = TRUE) use_qmd_htmlrecruitment(save_in = ".", open = TRUE) use_qmd_htmlsampsi(save_in = ".", open = TRUE) use_qmd_typst(save_in = ".", open = TRUE)
use_qmd_html(save_in = ".", open = TRUE) use_qmd_pres(save_in = ".", open = TRUE) use_qmd_htmlrecruitment(save_in = ".", open = TRUE) use_qmd_htmlsampsi(save_in = ".", open = TRUE) use_qmd_typst(save_in = ".", open = TRUE)
save_in |
directory to save the main qmd in |
open |
logical indicating whether to open the file |
use_qmd_pres()
: revealjs Presentation Template
use_qmd_htmlrecruitment()
: Recruitment Report Template
use_qmd_htmlsampsi()
: Sample Size Report Template
use_qmd_typst()
: Sample Size Report Template
# dir <- tempdir() # file <- file.path(dir, "filename.qmd") # use_qmd_html(file, FALSE) # in practice at CTU: # use_qmd_html("08_Reports_xx/ReportName.qmd", TRUE) # dir <- tempdir() # file <- file.path(dir, "filename.qmd") # use_qmd_pres(file, FALSE) # in practice at CTU: # use_qmd_pres("08_Reports_xx/ReportName.qmd", TRUE) # dir <- tempdir() # file <- file.path(dir, "filename.qmd") # use_qmd_html(file, FALSE) # in practice at CTU: # use_qmd_htmlrecruitment("08_Reports_xx/ReportName.qmd", TRUE) # dir <- tempdir() # file <- file.path(dir, "filename.qmd") # use_qmd_html(file, FALSE) # in practice at CTU: # use_qmd_htmlrecruitment("08_Reports_xx/ReportName.qmd", TRUE) # dir <- tempdir() # file <- file.path(dir, "filename.qmd") # use_qmd_html(file, FALSE) # in practice at CTU: # use_qmd_typst("08_Reports_xx/ReportName.qmd", TRUE)
# dir <- tempdir() # file <- file.path(dir, "filename.qmd") # use_qmd_html(file, FALSE) # in practice at CTU: # use_qmd_html("08_Reports_xx/ReportName.qmd", TRUE) # dir <- tempdir() # file <- file.path(dir, "filename.qmd") # use_qmd_pres(file, FALSE) # in practice at CTU: # use_qmd_pres("08_Reports_xx/ReportName.qmd", TRUE) # dir <- tempdir() # file <- file.path(dir, "filename.qmd") # use_qmd_html(file, FALSE) # in practice at CTU: # use_qmd_htmlrecruitment("08_Reports_xx/ReportName.qmd", TRUE) # dir <- tempdir() # file <- file.path(dir, "filename.qmd") # use_qmd_html(file, FALSE) # in practice at CTU: # use_qmd_htmlrecruitment("08_Reports_xx/ReportName.qmd", TRUE) # dir <- tempdir() # file <- file.path(dir, "filename.qmd") # use_qmd_html(file, FALSE) # in practice at CTU: # use_qmd_typst("08_Reports_xx/ReportName.qmd", TRUE)
Get a quarto template from the CTU-Bern quarto repository
use_quarto(x, dir, open = TRUE)
use_quarto(x, dir, open = TRUE)
x |
branch name of the template in question |
dir |
folder in which to save the template |
open |
logical, whether to open the file |
a qmd file (and extension file)
#use_quarto("html", ".")
#use_quarto("html", ".")
Open a new recruitment report
use_recreport_template(save_as, open = TRUE, ...)
use_recreport_template(save_as, open = TRUE, ...)
save_as |
filename to save the Rmd as |
open |
logical indicating whether to open the file |
... |
other arguments passed to |
Creates an Rmd file in the save_as
location
# use_recreport_template("rr.Rmd")
# use_recreport_template("rr.Rmd")
Open a new report
use_report_template(save_as, open = TRUE, ...)
use_report_template(save_as, open = TRUE, ...)
save_as |
filename to save the Rmd as |
open |
logical indicating whether to open the file |
... |
other arguments passed to |
Creates an Rmd file in the save_as
location
# use_report_template("foo.Rmd")
# use_report_template("foo.Rmd")
Open a new sample size report
use_ssreport_template(save_as, open = TRUE, ...)
use_ssreport_template(save_as, open = TRUE, ...)
save_as |
filename to save the Rmd as |
open |
logical indicating whether to open the file |
... |
other arguments passed to |
Creates an Rmd file in the save_as
location
# use_ssreport_template("ss.Rmd")
# use_ssreport_template("ss.Rmd")
Open a new tex template allowing customization
use_ub_tex_template(save_as, open = TRUE, ...)
use_ub_tex_template(save_as, open = TRUE, ...)
save_as |
filename to save the tex file as (should be the same as in the Rmd header) |
open |
logical indicating whether to open the file |
... |
other arguments passed to |
Creates an tex file in the save_as
location
# use_ub_tex_template("report.tex")
# use_ub_tex_template("report.tex")
The CLO file contains the information identifying the author, project and institution (although we do not modify that). It is used by the UNIBE CLS file to create the parts of the template.
use_ubreportclo( projnum = "xxx", projname = "Project YYY", reporttype = "Type of report", version = "Version", sign = "Author name", email = "[email protected]", job = "Senior Statistician", open = FALSE, dir = ".", ... )
use_ubreportclo( projnum = "xxx", projname = "Project YYY", reporttype = "Type of report", version = "Version", sign = "Author name", email = "[email protected]", job = "Senior Statistician", open = FALSE, dir = ".", ... )
projnum |
Project number to appear in report |
projname |
Project name to appear in report |
reporttype |
The main title of the report |
version |
Version number or similar |
sign |
Your name as it should appear |
email |
your email address |
job |
your job title |
open |
open the file or not |
dir |
directory in which to create the file |
... |
other options passed to |
writes the UNIBE template clo file
# use_ubreportclo(# Personal info # sign = "Alan", # email = "[email protected]", # job = "Senior Statistician", # # Project info # projnum = "1234", # projname = "Project X", # # Report info # version = Sys.Date(), # reporttype = "Recruitment report" # )
# use_ubreportclo(# Personal info # sign = "Alan", # email = "[email protected]", # job = "Senior Statistician", # # Project info # projnum = "1234", # projname = "Project X", # # Report info # version = Sys.Date(), # reporttype = "Recruitment report" # )