---
layout: post
title: "Benchmarking string manipulations with base R, stringi, and stringr (CC282)"
blurb: "stringi is really fast"
author: "PD Schloss"
date: 2024-05-09 11:00
comments: false
youtube: hRkotTsAjTg
start_hash: bc3ba05ef5a499d1d3792984b7e9e843ad38dd09
end_hash: 0848c315de2ec25638c2d0484a95fbe83349aa00
---

The phylotypr package does a lot of string manipulations using functions from base R. But are these the fastest options? This episode will compare base R string manipulations to those available in the stringi and stringr packages. We'll look at finding the length of strings, extracting substrings, replacing characters, and translating between character and base4 space. Wait until you see how much faster our code is after implementing the fastest versions of these operations! This episode is part of an ongoing effort to develop an R package that implements the naive Bayesian classifier.

<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/phylotypr/tree/{{page.start_hash}})
* [end of the episode](https://github.com/riffomonas/phylotyprr/tree/{{page.end_hash}})
