Answers for "remove first and last character from string R"

R
0

remove first and last character from string 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)
Posted by: Guest on September-22-2021

Code answers related to "remove first and last character from string R"

Browse Popular Code Answers by Language