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:

  <img  src="/img/canopy_bed.png" alt="Canopy Bed" width="304" height="228">
  <figcaption>Isn't this better than camping?</figcaption>
 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 which contains a link in the caption:

  <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>

Floating figure via html:

<!-- Margin parameters: top right bottom left -->
<figure style="float: left;margin:5px 10px 8px 5px">
  <img  src="/img/canopy_bed.png" alt="Canopy Bed" width="304" height="228">
  <figcaption>More comfortable than camping?</figcaption>
</figure> ```

#### Rmarkdown tips from Indrajeet Patil @patilindrajeets 

see [these tweets](https://indrajeetpatil.github.io/RmarkdownTips/).

#### 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](https://gohugo.io/content-management/shortcodes/#figure)
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” ">
Isn’t this better than camping?

{{< tweet 1390602863651573760 >}}

markdown code for figure: (html parameters within curly braces) (Text, italic in ())

{{% 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
2 minute read, 412 words
See Also: