Session Ready
Exercise

Parsing strings into variables

A common use for str_split() is to pull apart raw string data into more useful variables. In this exercise you'll start by pulling apart a date range, something like "23.01.2017 - 29.01.2017", into separate variables for the start of the range, "23.01.2017", and the end of the range, "29.01.2017".

Remember, if the simplify argument is FALSE (the default) you'll get back a list of the same length as that of the input vector. More commonly, you'll want to pull out the first piece (or second piece etc.) from every element, which is easier if you specify simplify = TRUE and get a matrix as output. You'll explore both of these output types in this exercise.

Instructions 1/4
undefined XP
  • 1
  • 2
  • 3
  • 4

Split date_ranges using " - " as a pattern, assign this to split_dates. Don't forget to wrap the pattern in fixed(). Print split_dates. The result is a list with two elements, since date_ranges was a vector of length two.