
The icons package for R makes adding web icons to reports,
presentations and apps easy. It integrates many popular icon libraries
from around the web with a simple interface that works with any
rmarkdown output format. If a particular icon library is not
explicitly supported by this package, you can still use it by creating a
custom icon set from a folder of SVG files. Icons provide flexible means
of digital expression, allowing expressions and functionality beyond
what is possible with emoji.
The icons package currently provides helpful tools for downloading and
using icons from these libraries:
The released version can be installed from CRAN using:
install.packages("icons")
The development version can be installed from GitHub using:
# install.packages("remotes")
remotes::install_github("mitchelloharawild/icons")
Once you’ve installed the package you’ll also need to download some
icons! Supported icon libraries (listed above) can be downloaded using
the download_*() functions. For example, to download the Font Awesome
icons you would use download_fontawesome().
library(icons)
Icons can be inserted inline using inline code
`r icons::fontawesome("rocket", style = "solid")`
or
`r icons::fontawesome$solid$rocket`
.
Icons can also be inserted using usual R chunks.
```{r icon-chunk}
fontawesome("rocket", style = "solid") # equivalent to icons::fontawesome$solid$rocket
```
If the icon name contains non-syntactic name characters like a - or
+, you will need to quote the name with backticks, single or double
quotes:
fontawesome$brands$`r-project` # or 'r-project' or "r-project"
The appearance of an icon can be customised using the icon_style()
function.
```{r icon-style}
icon_style(fontawesome("rocket", style = "solid"), scale = 2, fill = "red")
```
Custom icon sets can be created using the icon_set() function, which
accepts a directory of SVG files and allows them to be used as icons.
```{r icon-custom}
custom <- icons::icon_set("hex")
custom$icons
```
You can also search for icons using the icon_find() function, which
returns a vector of matching icons. Use icon_label() to see which icon
set and name each match came from.
found <- icon_find("rocket")
found
icon_label(found)
#> [1] "ionicons$rocket" "fontawesome$solid$rocket"
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.