시작하기무료로 시작하기

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.

이 연습은 강의의 일부입니다

String Manipulation with stringr in R

강의 보기

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Some date data
date_ranges <- c("23.01.2017 - 29.01.2017", "30.01.2017 - 06.02.2017")

# Split dates using " - "
split_dates <- ___
split_dates
코드 편집 및 실행