---
layout: post
title: "For loops in R: a tutorial on how to simplify your code without compromising performance (CC173)"
blurb: "High-performance for loops in base R"
author: "PD Schloss"
date: 2021-12-20 11:00
comments: false
youtube: hG7SSfBXVuM
start_hash: 966c744d50e4941b8b91e7867e49eca919973c76
end_hash: 29054557cd1e60e97ab5a3529358c60ab1dd29d4
---

For loops get a bad rap in R. In this tutorial, I'll share they syntax for writing a for loop and how we can use a for loop to simplify our code without compromising the performance of our code. This is part of a series of videos demonstrating how to functions from base R to make these data compatible with tools from the tidyverse.


<iframe style="margin: 0 auto;display:block;" width="560" height="315" src="https://www.youtube.com/embed/{{ page.youtube }}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>


## Code

You can browse the state of the repository at the
* [beginning of the episode](https://github.com/riffomonas/distances/tree/{{ page.start_hash }})
* [end of the episode](https://github.com/riffomonas/distances/tree/{{ page.end_hash }})
