Created
March 9, 2017 02:08
-
-
Save webbedfeet/ae7c0dbdad49e4bf25124ec4b742a46b to your computer and use it in GitHub Desktop.
Inserting a character at a particular point in a string using R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # To put a particular character _ after the 10th position in a string | |
| gsub('^([a-z]{10})([a-z]+)','\\1_\\2', x) | |
| # or | |
| library(stringr) | |
| str_replace(x, '^([a-z]{10})([a-z]+]','\\1_\\2') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment