Zacznij terazZacznij za darmo

Extracting age and gender again

You can now also take another look at your pattern for pulling out age and gender from the injury narratives. In the last chapter you took two steps to extract the pattern and then pull it apart. Take a go at doing it in one step!

To ćwiczenie jest częścią kursu

String Manipulation with stringr in R

Zobacz kurs

Interaktywne ćwiczenie praktyczne

Spróbuj tego ćwiczenia, uzupełniając ten przykładowy kod.

# narratives has been pre-defined
narratives

# Add capture() to get age, unit and sex
pattern <- optional(DGT) %R% DGT %R%  
  optional(SPC) %R% or("YO", "YR", "MO") %R%
  optional(SPC) %R% or("M", "F")

# Pull out from narratives
___
Edytuj i uruchom kod