June 2017
Beginner to intermediate
576 pages
15h 22m
English
Clean up the colors a little more by capitalizing all of the colors and inserting a delimiter:
col <- topper(paste0(col2, collapse = "|"))
Now pass the results to gsub():
cat("Pass to gsub\n", head(col, 9))
> Pass to gsub > WHITE||AZURE|BEIGE|BISQUE|BLACK|BLUE|BROWN|CORAL|CYAN|DARKRED|DIMGRAY|GOLD|GRAY|GREEN|HOTPINK|IVORY|KHAKI|LINEN|MAGENTA|MAROON|NAVY|OLDLACE|ORANGE|ORCHID|PERU|PINK|PLUM|PURPLE|RED|SALMON|SIENNA|SKYBLUE|SNOW|TAN|THISTLE|TOMATO|VIOLET|WHEAT|YELLOW
For example, to replace the colors in the dataframe with blanks:
OnlineRetail$Description <- gsub(col, "", OnlineRetail$Description)
Check the length to see how much was removed. As before, print the character count before and after, to ensure that ...