I have hospital ward data that needs to be consistent. The first numeric character is the floor number, the alphabet characters that follow is the ward acronym, and the final two numeric characters are the bed number.
So 2EA 28 would be floor 2, Ward East and Bed 28.
The locations have been entered in with inconsistent spaces such that I have the following:
toyraw<-data.table(incident_no = c(1:6), location =c("2EA17","2EA 17", "1ED1", "1ED23", "1ED 34","ICU24"))
I would like it to look like the following
toyideal<-data.table(incident_no = c(1:5), location =c("2EA 17","2EA 17", "1ED 1", "1ED 23", "1ED 34", "ICU 24"))
If there was no numeric at the front I would just sub out the numeric and the characters one at a time but because it is numeric, character numeric it is posing a problem. There are 1462 rows.
Further complications, ground floor wards such as the ICU have no preceding number.
Added as per request - human readable names
human readable names:
additional<-data.table(incident_no = c(1:5), location =c("2EA 17","2EA 17", "1ED 1", "1ED 23", "1ED 34"),
human_Readable = c("Ward 2 East Bed 17","Ward 2 East Bed 17", "Ward 1 Emergency Department
Bed 1", "Ward 1 Emergency Department Bed 23", "Ward 1 Emergency Department Bed 24",
"Ward ICU Bed 24"))