Promoting the use of R in the NHS

Blog Article

This post was originally published on this site

(This article was first published on rOpenSci – open tools for open science, and kindly contributed to R-bloggers)

Icons in R

The icon package provides a convenient interface for adding icons from popular web fonts to R Markdown documents. The project began at rOpenSci OzUnconf 2017, and was developed by Mitchell O’Hara-Wild, Earo Wang and Timothy Hyndman. The package currently supports icons from Font Awesome, Academicons, and ionicons.

Icons can be added to your R Markdown documents using short prefixes which identify the font’s library.

  • fa: Font Awesome
  • ai: Academicons
  • ii: ionicons

For example, `r icon::fa("rocket")` can be used to add the rocket icon from Font Awesome. This interface is convenient if you are familiar with the icon you want, or if you are dynamically selecting your icon.

The package also provides a second interface which allows for tab completion of font names. To include the rocket icon above, you could instead use `r icon::fa_rocket()`. This is a useful interface for if you are unfamiliar with the available icons or their names.

Each icon function also provides support for modifying the attributes of the icon such as size, colour, rotation, and animation. We can make the rocket icon spin using `r icon::fa_rocket(animate = "spin")`.

R in icons

The long-awaited R Project icon has been added to the Font Awesome library in version 5.0.11. This addition comes nearly four years since the icon’s first request after being brought into the spotlight of #rstats with LockeData’s tweet.

Finally, it is possible to use an R package to include the R icon in your R Markdown documents!

`r fa_rocket(colour = "#1FA67A")` + `r fa_r_project(colour = "#384CB7")` = `r fa_heart(colour = "red")`

Future development

There are plans to submit the icon package to CRAN, however there are a few things we would like to work on first. The top development priority is transitioning from web-font icons to svg icons. This should drastically reduce the load times of documents using icons, and allow the user to import their own icon libraries. Before release, we would also like to add further support for manipulating icons with modifier functions, and resolve an R Markdown issue relating to using icons within headers.

You can install and try out the latest version of the icon package today via:

devtools::install_github("ropenscilabs/icon")

To leave a comment for the author, please follow the link and comment on their blog: rOpenSci – open tools for open science.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more…

Comments are closed.