Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR R

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)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #character #string #R
ADD COMMENT
Topic
Name
4+6 =