НачатьНачать бесплатно

Final challenges

You've mastered using stringr functions on their own, but by combining multiple operations together in sequence you can achieve quite complicated manipulations.

As the final exercise we want to expose you to the power of combining operations. You'll complete two tasks:

  1. You'll turn a vector of full names, like "Bruce Wayne", into abbreviated names like "B. Wayne". This requires combining str_split(), str_sub() and str_c().

  2. You'll compare how many boy names end in "ee" compared to girl names. This requires combining str_sub() with str_detect() along with the base function table().

Это упражнение является частью курса

String Manipulation with stringr in R

Посмотреть курс

Интерактивное практическое упражнение

Попробуйте выполнить это упражнение, дополнив этот пример кода.

# Define some full names
names <- c("Diana Prince", "Clark Kent")

# Split into first and last names
names_split <- ___

# Extract the first letter in the first name
abb_first <- ___

# Combine the first letter ". " and last name
___
Редактировать и запускать код