README.md

salim

CRAN Status

salim includes a diverse mix of functions which have not found their home in a more suitable place yet. The package kinda serves as an incubator for not yet fully matured code and thus will most probably never be made available through CRAN.

This is arguably a low-cohesion package.

Documentation

Netlify Status

The documentation of this package is found here.

Installation

To install the latest development version of salim, run the following in R:

if (!("remotes" %in% rownames(installed.packages()))) {
  install.packages(pkgs = "remotes",
                   repos = "https://cloud.r-project.org/")
}

remotes::install_gitlab(repo = "salim_b/r/pkgs/salim")

Package configuration

Some of salim’s functionality is controlled via package-specific global configuration which can either be set via R options or environment variables (the former take precedence). This configuration includes:

::: table-wide | Description | R option | Environment variable | Default value | |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------|:---------------------------|:------------------| | Locale identifier consisting of a ISO 639-1 or ISO 639-3 language code plus an optional country identifier separated by a hyphen (-). For example "fr" or "de-CH". | salim.locale | R_SALIM_LOCALE | "en-US" | | Body font family for plot theming functions. | salim.font_family_body | R_SALIM_FONT_FAMILY_BODY | "Alegreya Sans" | | Body color for plot theming functions. | salim.plot_color_body | R_SALIM_PLOT_COLOR_BODY | "#343a40" | | Background color for plot theming functions. | salim.plot_color_bg | R_SALIM_PLOT_COLOR_BG | "#f2f2f2" | | Grid color for plot theming functions. | salim.plot_color_grid | R_SALIM_PLOT_COLOR_GRID | "#d9d9d9" | :::

Development

R Markdown format

This package’s source code is written in the R Markdown file format to facilitate practices commonly referred to as literate programming. It allows the actual code to be freely mixed with explanatory and supplementary information in expressive Markdown format instead of having to rely on # comments only.

All the .gen.R suffixed R source code found under R/ is generated from the respective R Markdown counterparts under Rmd/ using pkgpurl::purl_rmd()[^1]. Always make changes only to the .Rmd files – never the .R files – and then run pkgpurl::purl_rmd() to regenerate the R source files.

Coding style

This package borrows a lot of the Tidyverse design philosophies. The R code is guided by the Tidy design principles and is formatted according to the Tidyverse Style Guide (TSG) with the following exceptions:

Furthermore, the preferred style for breaking long lines differs. Instead of wrapping directly after an expression’s opening bracket as suggested by the TSG, we prefer two fewer line breaks and indent subsequent lines within the expression by its opening bracket:

``` r # TSG proposes this do_something_very_complicated( something = "that", requires = many, arguments = "some of which may be long" )

# we prefer this do_something_very_complicated(something = "that", requires = many, arguments = "some of which may be long") ```

This results in less vertical and more horizontal spread of the code and better readability in pipes.

As far as possible, these deviations from the TSG plus some additional restrictions are formally specified in pkgpurl::default_linters, which is (by default) used in pkgpurl::lint_rmd(), which in turn is the recommended way to lint this package.

See also

[^1]: The very idea to leverage the R Markdown format to author R packages was originally proposed by Yihui Xie. See his excellent blog post for his point of view on the advantages of literate programming techniques and some practical examples. Note that using pkgpurl::purl_rmd() is a less cumbersome alternative to the Makefile approach outlined by him.

[^2]: The TSG explicitly instructs to avoid this operator – presumably because it’s relatively unknown and therefore might be confused with the forward pipe operator %>% when skimming code only briefly. I don’t consider this to be an actual issue since there aren’t many sensible usage patterns of %>% at the beginning of a pipe sequence inside a function – I can only think of creating side effects and relying on R’s implicit return of the last evaluated expression. Therefore – and because I really like the %<>% operator – it’s usage is welcome.

[^3]: The TSG explicitly accepts -> for assignments at the end of a pipe sequence while Google’s R Style Guide considers this bad practice because it “makes it harder to see in code where an object is defined”. I second the latter.



salim-b/salim documentation built on June 10, 2025, 9:28 p.m.