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

The colors() function

The colors() function returns a list of colors that are used in the current palette. We can then perform a little code manipulation in conjunction with the gsub() function that we just used to replace all of the specified colors from OnlineRetail$Description with blanks.

We will also use the kable() function, which is contained within the knitr package, in order to produce simple HTML tables of the results:

# compute the length of the field before changes before <- sum(nchar(OnlineRetail$Description)) # get the unique colors returned from the colors function, and remove any digits found at the end of the string # get the unique colors col2 <- unique(gsub("[0-9]+", "", colors(TRUE))) #Now we will filter out any colors ...

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