Package 'iheiddown'

Title: For Writing Geneva Graduate Institute Documents
Description: A set of tools for writing documents according to Geneva Graduate Institute conventions and regulations. The most common use is for writing and compiling theses or thesis chapters, as drafts or for examination with correct preamble formatting. However, the package also offers users to create HTML presentation slides with 'xaringan', complete problem sets, format posters, and, for course instructors, prepare a syllabus. The package includes additional functions for institutional color palettes, an institutional 'ggplot' theme, a function for counting manuscript words, and a bibliographical analysis toolkit.
Authors: James Hollway [aut, cre, cph] , Bernhard Bieri [ctb] , Henrique Sposito [ctb]
Maintainer: James Hollway <[email protected]>
License: MIT + file LICENSE
Version: 0.9.7
Built: 2025-03-12 05:33:32 UTC
Source: https://github.com/iheid-library/iheiddown

Help Index


Advance dates by week

Description

This function takes a start date, e.g. of a course, and advances it by a number of weeks. This function is used in the syllabus template.

Usage

advdate(startdate, week)

Arguments

startdate

The first date in the series (e.g. first day of class).

week

The number of weeks into the series. Week 1 is the first date in the series.

Value

A vector of dates in the format "dd mmm" in parentheses.

Examples

advdate("2021-06-23", 1:3)

Reporting bibliographic statistics

Description

These functions are useful for calculating salient statistics on the bibliographies used for dissertations or syllabi. They include the following functions/metrics:

Usage

percent_female(bib_file, rmd_file, by = c("author", "publication"))

mean_year(bib_file, rmd_file)

mean_pages(bib_file, rmd_file)

total_pages(bib_file, rmd_file)

Arguments

bib_file

A .bib file for the project. If not given, the functions will search for a .bib file in the folder associated with the file the source editor has open.

rmd_file

A .rmd file If not given, the functions will check to see whether the current file open in the source editor is an .rmd file, and if so use that.

by

A string in c("author", "publication") which determines if the percentage of female authors is computed across all papers or the percentage represents the proportion of papers written by at least one woman.

Details

percent_female()

Displays the percentage of authors in a .bib file that are female. See the {gender} package for more details.

mean_year()

Displays the average year of publication of the items in a given .bib file.

mean_pages()

Displays the average number of pages of the items in a given .bib file.

total_pages()

Displays the total number of pages of all items in a given .bib file.

Value

Prints a summary statistic (e.g. mean or proportion)


Manage iheiddown profile

Description

This RStudio Addin opens up the ~/_bookdown.yml file for users to edit. If the file doesn't exists, it will create one.

Usage

bookdown_profile()

Value

Opens or creates a bookdown profile YAML file for the current thesis.


Creates an R Markdown PDF Thesis chapter

Description

This function can be used in the header of each constituent chapter of an IHEID thesis to output a draft version of the chapter for proofreading or sending to your supervisor.

Usage

chapter_pdf(input, ...)

Arguments

input

Rmd input file that will be processed by the function.

...

Instructions passed to the function from a correctly specified .Rmd document

Value

A modified pdf_document based on the IHEID Thesis LaTeX template

Examples

## Not run: 
knit: iheiddown::chapter_pdf

## End(Not run)

A function for counting words in an Rmarkdown document.

Description

This function takes a path to a .Rmd file and returns a word count. For best results each sentence should start on a new line. Inline code chunks should also start on a new line.

Usage

count_words(file)

count_words2(file)

Arguments

file

A path to a .Rmd file

Value

A scalar representing the number of words in the document.

Examples

rmarkdown::draft(file = "test", template = "html_vignette",
package = "rmarkdown", create_dir = TRUE, edit = FALSE)
iheiddown::count_words("test/test.Rmd")
unlink("test", recursive = TRUE)

An IHEID palette generator

Description

These are a few color palettes useful for members of the Geneva Graduate Institute. This function calls one of three official palettes in iheid_palette: for the Institute, for the Centres, and for the SDGs.

Usage

iheid_palette(name, n, type = c("discrete", "continuous"))

Arguments

name

Name of desired palette. Current choices are: IHEID, Centres, and SDGs.

n

Number of colors desired. If omitted, uses all colours.

type

Either "continuous" or "discrete". Use continuous if you want to automatically interpolate between colours.

Value

A vector of colours.

Source

Adapted from https://github.com/karthik/wesanderson/blob/master/R/colors.R

Examples

iheid_palette("IHEID")
iheid_palette("Centres")
iheid_palette("SDGs")

# If you need more colours than normally found in a palette, you
# can use a continuous palette to interpolate between existing
# colours
pal <- iheid_palette(21, name = "Centres", type = "continuous")
image(volcano, col = pal)

Complete list of palettes

Description

Use iheid_palette to construct palettes of desired length.

Usage

iheid_palettes

Format

An object of class list of length 3.


Posterdown inspired HTML posters

Description

These functions render different versions of the original {posterdown} templates with a little IHEID twist to them. All exports are in HTML format. You can save them by printing them to PDF via a modern browser.

The output format poster_betterland() mimics the style of the BetterPoster movement from twitter with an IHEID twist.

The output format poster_betterport() mimics the style of the BetterPoster movement from twitter with an IHEID twist.

Usage

iheiddown_poster(
  ...,
  template = system.file("rmarkdown", "templates", "iheiddown_poster", "resources",
    "template.html", package = "iheiddown"),
  css = NULL
)

iheiddown_betterland(
  ...,
  template = system.file("rmarkdown", "templates", "iheiddown_betterland", "resources",
    "template.html", package = "iheiddown"),
  css = NULL
)

iheiddown_betterport(
  ...,
  template = system.file("rmarkdown", "templates", "iheiddown_betterport", "resources",
    "template.html", package = "iheiddown"),
  css = NULL
)

Arguments

...

Additional arguments to rmarkdown::html_document

template

Additional argument passed to pagedown::poster_relaxed. IHEID poster templates by default.

css

Additional argument passed to pagedown::poster_relaxed. NULL by default.

Value

R Markdown output format to pass to rmarkdown::render()

Source

{Posterdown}

Examples

## Not run: 
file <- file.path(tempdir(),"foo.rmd")
rmarkdown::draft(file, template="iheiddown_poster", package="iheiddown")

## End(Not run)

Previewing rmarkdown documents

Description

Use the servr package to continuously serve and reload the Rmd document. Run preview_start() function while viewing the Rmd panel of your presentation. To stop the server, run preview_stop().

Usage

preview_start(file_path, ...)

preview_stop(which = NULL)

Arguments

file_path

The input Rmd file path (if missing and in RStudio, the current active document is used).

...

Additional arguments passed to rmarkdown::render().

which

An integer vector of the server IDs; by default, IDs of all existing servers in the current R session obtained from daemon_list(), i.e., all daemon servers will be stopped by default.

Value

Starts serving the current files to RStudio's Viewer pane.

Stops serving the current files to RStudio's Viewer pane.

References

xaringan


Creates an R Markdown PDF Problem Set document

Description

This is a function called in output in the YAML of the driver Rmd file to specify using the IHEID Problem Set LaTeX template file.

Usage

problemset_pdf(input, ...)

Arguments

input

The name of the .Rmd file to serve as input.

...

Instructions passed to the function from a correctly specified .Rmd document

Value

A modified pdf_document based on the IHEID Problem Set LaTeX template, automatically named by course and date.

Examples

## Not run: 
output:
  iheiddown::problemset_pdf:
    input: "Untitled.Rmd"
    # Replace with whatever the name of this file is, e.g. "MINT001.Rmd"

## End(Not run)

Creates an R Markdown PDF Syllabus document

Description

This is a function called in output in the YAML of the driver Rmd file to specify using the IHEID Syllabus LaTeX template file.

Usage

syllabus_pdf(input, ...)

Arguments

input

The name of the .Rmd file to serve as input.

...

Instructions passed to the function from a correctly specified .Rmd document

Value

A modified pdf_document based on the IHEID Syllabus LaTeX template, automatically named by course and date.

Examples

## Not run: 
output:
  iheiddown::syllabus_pdf:
    input: "Untitled.Rmd" 
    # Replace with whatever the name of this file is, e.g. "MINT001.Rmd"

## End(Not run)

A ggplot2 theme for IHEID style plots. Adapted from Hrbrmstr's ipsum theme.

Description

A ggplot2 theme for IHEID style plots. Adapted from Hrbrmstr's ipsum theme.

Usage

theme_iheid(
  base_family = "sans",
  base_size = 11.5,
  plot_title_family = base_family,
  plot_title_size = 18,
  plot_title_face = "bold",
  plot_title_margin = 10,
  subtitle_family = base_family,
  subtitle_size = 12,
  subtitle_face = "plain",
  subtitle_margin = 15,
  strip_text_family = base_family,
  strip_text_size = 12,
  strip_text_face = "plain",
  caption_family = base_family,
  caption_size = 9,
  caption_face = "italic",
  caption_margin = 10,
  axis_text_size = base_size,
  axis_title_family = subtitle_family,
  axis_title_size = 9,
  axis_title_face = "plain",
  axis_title_just = "rt",
  plot_margin = margin(30, 30, 30, 30),
  grid_col = "grey85",
  grid = TRUE,
  axis_col = iheid_palette("IHEID")["IHEIDBlack"],
  axis = FALSE,
  ticks = FALSE
)

Arguments

base_family, base_size

base font family and size

plot_title_family, plot_title_face, plot_title_size, plot_title_margin

plot title family, face, size and margi

subtitle_family, subtitle_face, subtitle_size

plot subtitle family, face and size

subtitle_margin

plot subtitle margin bottom (single numeric value)

strip_text_family, strip_text_face, strip_text_size

facet label font family, face and size

caption_family, caption_face, caption_size, caption_margin

plot caption family, face, size and margin

axis_text_size

font size of axis text

axis_title_family, axis_title_face, axis_title_size

axis title font family, face and size

axis_title_just

axis title font justification, one of ⁠[blmcrt]⁠

plot_margin

plot margin (specify with ggplot2::margin())

grid_col, axis_col

grid & axis colors; both default to ⁠#cccccc⁠

grid

panel grid (TRUE, FALSE, or a combination of X, x, Y, y)

axis

add x or y axes? TRUE, FALSE, "xy"

ticks

ticks if TRUE add ticks

Value

Themes the current ggplot to current IHEID guidelines.

Examples

library(ggplot2)
library(dplyr)

# seminal scatterplot
ggplot(mtcars, aes(mpg, wt)) +
  geom_point() +
  labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
       title="Seminal ggplot2 scatterplot example",
       subtitle="A plot that is only useful for demonstration purposes",
       caption="Brought to you by the letter 'g'") +
  theme_iheid()

# seminal bar chart
count(mpg, class) %>%
  ggplot(aes(class, n)) +
  geom_col() +
  geom_text(aes(label=n), nudge_y=3) +
  labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
       title="Seminal ggplot2 bar chart example",
       subtitle="A plot that is only useful for demonstration purposes",
       caption="Brought to you by the letter 'g'") +
  theme_iheid(grid="Y") +
  theme(axis.text.y=element_blank())

Creates an R Markdown PDF Thesis document

Description

This is a function called in output in the YAML of the driver Rmd file to specify using the IHEID Thesis LaTeX template file.

Usage

thesis_pdf(input = ".", ...)

Arguments

input

Rmd input file that will be processed by the function.

...

Instructions passed to the function from a correctly specified .Rmd document

Value

A modified pdf_document based on the IHEID Thesis LaTeX template

Examples

## Not run: 
knit: iheiddown::thesis_pdf

## End(Not run)