O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Simplifying the descriptions

Market basket analysis using color choice analysis is an interesting topic in itself. However, for this analysis, we will remove some of the colors in order to simplify some of the descriptions. We will use the gsub() function to remove some of the specific colors that appear as part of the product description. Since the gsub() function only works on a single string or pattern at one time, set up a function to pass multiple strings to the gsub() function.

This gsub_multiple function will take a character vector (x), and change all strings supplied in from to their corresponding values in to. In our case, we want to eliminate them from the text, so our to strings will always be "":

 gsub_multiple <- function(from, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required