From the course: R for Data Science: Lunch Break Lessons

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

chartr

chartr

- [Instructor] R has several string manipulation functions, and chart R is one of the more convenient of all of them. Let's take a look. The first thing I've done is created a vector called haystack, and into it, I've placed red, green, blue, blue, green forest. It's up there in the upper left hand corner, and let's use chart R to do a quick translation. The way I use this is chart R and I say these are the letters to search for in this order. Here is what I'd like to translate those letters into, and we'll use some sort of nonsense here. And then finally, here is the vector I want you to search. And I run that command and you can see that red has been untouched because I'm not searching for R or E or D, and blue is untouched, but green, you'll notice that the N in green has been replaced with an under bar. That's because I was searching for A or N or S and replacing with ampersand, under bar, star. So you'll notice that the N in green has been replaced with an under bar, and the S…

Contents