June 2017
Beginner to intermediate
576 pages
15h 22m
English
We can start by removing leading and trailing blanks from each of the product descriptions, since they add no value to the analysis and just take up extra space. trimws is a handy function to accomplish this, since it removes both leading and trailing spaces. The nchar() function will count the number of bytes in a character string, so we can run this function on OnlineRetail$Description before and after performing the string trim to see how much space we will actually be saving:
sum(nchar(OnlineRetail$Description))
This is the resulting output:
> [1] 14284888
Continue the following code:
OnlineRetail$Description <- trimws(OnlineRetail$Description)sum(nchar(OnlineRetail$Description))
This is the resulting ...