Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Icons in R
The icon package provides a convenient interface for adding icons from popular web s 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 ’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 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.
Hey, the #rstats logo is #40 on the @awesome brand board – go give it some ? so we can get it higher!https://t.co/jdEcVMJyip
— Locke Data (@LockeData) April 20, 2018
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- 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")
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.