R Holen Sie sich ein spezifisches Zeichen von der Zeichenfolge
string_var = "this is an example"
# substr(string, first_char_pos, last_char_pos) # extracts characters from pos1 to pos2
substr(x, 1, 3) # Extract first three characters
# "thi"
substr(x, 4, 4) # Extract only the fourth character
# "s"
n_last <- 3 # Specify number of characters to extract
# nchar(x) counts total no. of characters in the string
substr(x, nchar(x) - n_last + 1, nchar(x)) # Extract last three characters
# "ple"
Dead Dragonfly