Use below code -
If the elements within the field have fixed length then directly give the position values like below -
substring(table$field_name,4,8)
If the length of elements in the field is varying then use nchar() to find the length of string like below -
substring(table$field_name,nchar(table$field_name)-4,nchar(table$field_name))