удалить первый и последний символ из строки R

# Two Methods to remove the first and last characters from a string variable in R:
# Example string
string = "%_adcknqwe4adflewgfgfrgaqe23_%"

# Using gsub
string_gsub <- gsub(pattern = '^.|.$', replacement = '', x = string)

# Using substr + counting characters w/ nchar():
string_substr <- substr(string, start=2, stop=nchar(string)-1)
Dead Dragonfly