<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/ligature-fonts-for-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://benjaminlmoore.wordpress.com/2017/07/19/ligature-fonts-for-r/"> R – Benomics</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Ligature fonts are fonts which sometimes map multiple characters to a single glyph, either for readability or just because it looks neat. Importantly, this only affects the rendering of the text with said font, while the distinct characters remain in the source.</p>
<div data-shortcode="caption" class="wp-caption"><img data-orig-file="https://benjaminlmoore.files.wordpress.com/2017/07/screen-shot-2017-07-19-at-20-39-24.png?w=456" data-orig-size="1798,444" data-medium-file="https://benjaminlmoore.files.wordpress.com/2017/07/screen-shot-2017-07-19-at-20-39-24.png?w=456?w=300" data-attachment-id="979" data-image-meta="{" data-image-description="" src="https://benjaminlmoore.files.wordpress.com/2017/07/screen-shot-2017-07-19-at-20-39-24.png?w=456" data-permalink="https://benjaminlmoore.wordpress.com/2017/07/19/ligature-fonts-for-r/screen-shot-2017-07-19-at-20-39-24/" data-large-file="https://benjaminlmoore.files.wordpress.com/2017/07/screen-shot-2017-07-19-at-20-39-24.png?w=456?w=500" alt="Screen Shot 2017-07-19 at 20.39.24" data-image-title="Screen Shot 2017-07-19 at 20.39.24" sizes="(max-width: 500px) 100vw, 500px" data-comments-opened="1" class="wp-image-979" data-recalc-dims="1">
<p class="wp-caption-text">The Apple Chancery font with and without ligatures enabled.</p>
</div>
<p>Maybe ligatures are an interesting topic in themselves if you’re into typography, but it’s the relatively modern monospaced variants which are significantly more useful in the context of R programming.</p>
<p>Two of the most popular fonts in this category are:</p>
<ul>
<li><a rel="nofollow" href="https://github.com/tonsky/FiraCode" target="_blank">Fira Code </a>— an extension of Fira Mono which really goes all out providing a wide range of ligatures for obscure Haskell operators, as well as the more standard set which will be used when writing R</li>
<li><a rel="nofollow" href="https://github.com/i-tu/Hasklig" target="_blank">Hasklig</a> — a fork of Source Code Pro (in my opinion a nicer base font) which is more conservative with the ligatures it introduces</li>
</ul>
<p>Here’s some code to try out with these ligature fonts, first rendered via bog-standard monospace font:</p>
<pre>
library(magrittr)
library(tidyverse)

filtered_storms &lt;- dplyr::storms %>%
  filter(category == 5, year &amp;gt;= 2000) %>%
  unite(&quot;date&quot;, year:day, sep = &quot;-&quot;) %>%
  group_by(name) %>%
  filter(pressure == max(pressure)) %>%
  mutate(date = as.Date(date)) %>%
  arrange(desc(date)) %>%
  ungroup() %T>%
  print()
</pre>
<p>Here’s the same code rendered with Hasklig:</p>
<p><img data-orig-file="https://benjaminlmoore.files.wordpress.com/2017/07/hasklig.png?w=456" data-orig-size="792,464" data-medium-file="https://benjaminlmoore.files.wordpress.com/2017/07/hasklig.png?w=456?w=300" data-attachment-id="985" data-image-meta="{" data-image-description="" src="https://benjaminlmoore.files.wordpress.com/2017/07/hasklig.png?w=456" data-permalink="https://benjaminlmoore.wordpress.com/2017/07/19/ligature-fonts-for-r/hasklig/" data-large-file="https://benjaminlmoore.files.wordpress.com/2017/07/hasklig.png?w=456?w=500" alt="hasklig.png" data-image-title="hasklig" sizes="(max-width: 500px) 100vw, 500px" data-comments-opened="1" class="wp-image-985" data-recalc-dims="1"></p>
<p>Some of the glyphs on show here are:</p>
<ul>
<li>A single arrow glyph for less-than hyphen (&lt;-)</li>
<li>Altered spacing around two colons (::)</li>
<li>Joined up double-equals</li>
</ul>
<p>Fira Code takes this a bit further and also converts >= to a single glyph:</p>
<p><img data-orig-file="https://benjaminlmoore.files.wordpress.com/2017/07/fira_code.png?w=456" data-orig-size="814,460" data-medium-file="https://benjaminlmoore.files.wordpress.com/2017/07/fira_code.png?w=456?w=300" data-attachment-id="987" data-image-meta="{" data-image-description="" src="https://benjaminlmoore.files.wordpress.com/2017/07/fira_code.png?w=456" data-permalink="https://benjaminlmoore.wordpress.com/2017/07/19/ligature-fonts-for-r/fira_code/" data-large-file="https://benjaminlmoore.files.wordpress.com/2017/07/fira_code.png?w=456?w=500" alt="fira_code" data-image-title="fira_code" sizes="(max-width: 500px) 100vw, 500px" data-comments-opened="1" class="wp-image-987" data-recalc-dims="1"></p>
<p>In my opinion these fonts are a nice and clear way of reading and writing R. In particular the single arrow glyph harks back to the APL keyboards with real arrow keys, for which our modern two-character &lt;-is a poor substitute.</p>
<p>One downside could be a bit of confusion when showing your IDE to someone else, or maybe writing slightly longer lines than it appears, but personally I’m a fan and my RStudio is now in Hasklig.</p>
<p> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benjaminlmoore.wordpress.com/964/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/comments/benjaminlmoore.wordpress.com/964/"></a> <img border="0" alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" data-recalc-dims="1"></p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://benjaminlmoore.wordpress.com/2017/07/19/ligature-fonts-for-r/"> R – Benomics</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/vCBXRlYqcwk" height="1"></a></div>