The output result of executing the above code is:
"ello"
"app" "ban" "che"
"Hello WORLD"
substr() is often used to extract fixed-format coded information:
Example
# Extract birth year from ID number (positions 7-10)
id_numbers <-c("110101199001011234", "310105198505067890")
birth_years <-substr(id_numbers, 7, 10)
print(paste("Birth year:", birth_years))
The output result of executing the above code is:
"Birth year: 1990" "Birth year: 1985"
YouTip