R Tips and Techniques

I have been saving R-related snippets in Evernote. What I will do here is pick out some of the ones that I use most often to try to organize them in a more curated fashion.

Markdown, HTML, and Hugo Shortcodes

link to Hugo shortcodes

To insert a figure:

<figure> 
  <img  src="/img/canopy_bed.png" alt="Canopy Bed" width="304" height="228">
  <figcaption>Isn't this better than camping?</figcaption>
</figure> 
 img style="float: right;" src="/img/taxi.png"> 
<figure.right  > 
  <img  src="/img/taxi.png" alt="taxi phone number" ">
  <figcaption>Isn't this better than camping?</figcaption>
</figure>

Figure which contains a link in the caption:

<figure> 
  <img  src="https://www.ldwa.org.uk/ldp/images/TF/517-1-L.png" alt="Canopy Bed">
  <figcaption>Elevation along the <a href="https://www.ldwa.org.uk/ldp/members/show_path.php?menu_type=S&path_name=West+Highland+Way">West Highland Way (Long Distance Walkers Association)</a> </figcaption>
</figure> 

A relative reference

In an .md document: [Choosing a path]({{< relref “2017-03-11-american-walker-in-britain-part-2.md#choosing-a-path” >}}) In an RMarkdown document, it’s different if pandoc is turning the document into html rather than Hugo.

#### [Back to UK Walking Topics]({{< relref "2017-03-07-an-american-walking-in-britain.md#topics" >}})

- [Choosing a path]({{< relref "2017-03-11-american-walker-in-britain-part-2.md#choosing-a-path" >}})

Hugo figure shortcode

and {{% figure src="/img/taxi.png#floatright" caption="Need a taxi Hadrians Wall Path?" %}}
 img style="float: right;" src="/img/taxi.png"> 
<figure.right  > 
  <img  src="/img/taxi.png" alt="taxi phone number" ">
  <figcaption>Isn't this better than camping?</figcaption>
   
</figure>

{{< tweet 1390602863651573760 >}}

markdown code for figure: (html parameters within curly braces)
![(*Text, italic in ()*)](/img/hugo_pool/page_inspector.jpg){width=100%}

{{% figure src="/img/taxi.png#floatright" caption="Need a taxi Hadrians Wall Path?" %}}

Have to use shortcode function to embed shortcode from RMarkdown:
blogdown::shortcode("figure", src = "/img/taxi.png#floatright", caption = "Called using shortcode function")

Called using shortcode function

Called using shortcode function

workflow for blogdown and netlify
a spoonful of hugo

Regular Expressions

Some tips from the Jumping Rivers blog

Posted on:
May 9, 2021
Length:
2 minute read, 377 words
See Also: