Package 'CTUtemplate'

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

Help Index


Insert CTU standard header to the active document This function is not intended to be used in any scripts.

Description

Insert CTU standard header to the active document This function is not intended to be used in any scripts.

Usage

add_ctu_header()

Value

adds CTU header to the active document


Colour specific text in a html document

Description

Colour specific text in a html document

Usage

coloured_text(colour, ...)

Arguments

colour

colour to use for the content

...

content to be coloured

Details

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

Examples

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!")

OneStageSS

Description

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.

Usage

OneStageSS(p0, p1, power = 0.8, n = NA, alpha = 0.05, nstart = 1)

Arguments

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

Value

List with number of patients with events for a significant trial (r), number of patients (n), alpha and power.

Examples

# 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)

Generate PDF report

Description

This is not intended to be run manually... rather via knitting a document

Usage

report_pdf(
  report_template = find_resource("report", "report.tex"),
  latex_engine = "pdflatex",
  ...
)

Arguments

report_template

tex template to use

latex_engine

tex engine to use (pdflatex, lualatex, xelatex)

...

options passed to bookdown


UNIBE red Get the official UNIBE red colour. Note that the unibeCols package has all of the UNIBE colours.

Description

UNIBE red Get the official UNIBE red colour. Note that the unibeCols package has all of the UNIBE colours.

Usage

unibeRed(alpha = 1)

Arguments

alpha

alpha for transparency (0 to 1)

Value

hexidecimal colour code

See Also

[unibeCols::unibeRed()]

Examples

plot(1:5, col = unibeRed())

Template files for a parameterized report

Description

Parameterized reports allow to create reports in a loop. Examples might be site specific quality reports or recruitment reports.

Usage

use_param_report_template(save_as, open = TRUE, ...)

Arguments

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 use_template

Details

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.

Value

saves two files, an Rmd and an R file

Examples

# 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.

Description

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.

Usage

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)

Arguments

save_in

directory to save the main qmd in

open

logical indicating whether to open the file

Functions

  • 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

Examples

# 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

Description

Get a quarto template from the CTU-Bern quarto repository

Usage

use_quarto(x, dir, open = TRUE)

Arguments

x

branch name of the template in question

dir

folder in which to save the template

open

logical, whether to open the file

Value

a qmd file (and extension file)

Examples

#use_quarto("html", ".")

Open a new recruitment report

Description

Open a new recruitment report

Usage

use_recreport_template(save_as, open = TRUE, ...)

Arguments

save_as

filename to save the Rmd as

open

logical indicating whether to open the file

...

other arguments passed to use_template

Value

Creates an Rmd file in the save_as location

Examples

# use_recreport_template("rr.Rmd")

Open a new report

Description

Open a new report

Usage

use_report_template(save_as, open = TRUE, ...)

Arguments

save_as

filename to save the Rmd as

open

logical indicating whether to open the file

...

other arguments passed to use_template

Value

Creates an Rmd file in the save_as location

Examples

# use_report_template("foo.Rmd")

Open a new sample size report

Description

Open a new sample size report

Usage

use_ssreport_template(save_as, open = TRUE, ...)

Arguments

save_as

filename to save the Rmd as

open

logical indicating whether to open the file

...

other arguments passed to use_template

Value

Creates an Rmd file in the save_as location

Examples

# use_ssreport_template("ss.Rmd")

Open a new tex template allowing customization

Description

Open a new tex template allowing customization

Usage

use_ub_tex_template(save_as, open = TRUE, ...)

Arguments

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 use_template

Value

Creates an tex file in the save_as location

Examples

# use_ub_tex_template("report.tex")

Generate the CLO file for use with the UNIBE tex template

Description

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.

Usage

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 = ".",
  ...
)

Arguments

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 use_template

Value

writes the UNIBE template clo file

Examples

# 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"
#                 )