Data wrangling, is the process of importing, cleaning and transforming raw data into actionable information for analysis. It is a time-consuming process which is estimated to take about 60-80% of analyst’s time. In this series we will go through this process. It will be a brief series with goal to craft the reader’s skills on the data wrangling task. This is the fourth part of the series and it aims to cover the cleaning of data used. At previous parts we learned how to import, reshape and transform data. The rest of the series will be dedicated to the data cleansing process. On this post we will go through the regular expressions, a sequence of characters that define a search pattern, mainly
for use in pattern matching with text strings.In particular, we will cover the foundations of regular expression syntax.
Before proceeding, it might be helpful to look over the help pages for the
Moreover please run the following commands to create the strings that we will work on.
bio <- c('24 year old', 'data scientist', '1992', 'A.I. enthusiast', 'R version 3.4.0 (2017-04-21)',
'r-exercises author', 'R is cool', 'RR')
If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.
Find the strings with Numeric values between 3 and 6.
Find the strings with the character ‘A’ or ‘y’.
Find any strings that have non-alphanumeric characters.
Remove lower case letters.
Remove space or tabs.
Remove punctuation and replace it with white space.
Remove alphanumeric characters.
Match sentences that contain ‘M’.
Match states with two ‘o’.
Match cars with one or two ‘e’.