I used police_officer <- str_extract_all(txtparts, "ID:.*\n")
to extract all the names of the police officers involved in a 911 call from a text file.
example:
2237 DISTURBANCE Report taken
Call Taker: Telephone Operators Sharon L Moran
Location/Address: [BRO 6949] 61 WILSON ST
ID: Patrolman Darvin Anderson
Disp-22:43:39 Arvd-22:48:57 Clrd-23:49:45
ID: Patrolman Stephen T Pina
Disp-22:43:48 Clrd-22:46:10
ID: Sergeant Michael V Damiano
Disp-22:46:33 Arvd-22:47:14 Clrd-22:55:22
In some parts when it matches more than one ID:
I get: "c(\" Patrolman Darvin Anderson\\n\", \" Patrolman Stephen T Pina\\n\", \" Sergeant Michael V Damiano\\n\")"
.
Here is what I have tried so far to clean the data:
police_officer <- str_replace_all(police_officer,"c\\(.","")
police_officer <- str_replace_all(police_officer,"\\)","")
police_officer <- str_replace_all(police_officer,"ID:","")
police_officer <- str_replace_all(police_officer,"\\n\","") # I can't get rid of\\n\.
this is what I end up with
" Patrolman Darvin Anderson\\n\", \" Patrolman Stephen T Pina\\n\", \" Sergeant Michael V Damiano\\n\""
I need help cleaning \\n\
.