Home > Net >  Remove illegal character
Remove illegal character

Time:11-22

In a dataframe frame like this:

data.frame(term = c("clear text","character <U C6C3>","<e9>guret text"))

Is there any command which could provide the removal of the character inside the <>

Example output:

data.frame(term = c("clear text","character","guret text"))

CodePudding user response:

Simple usage of gsub and trimws.

data <- data.frame(term = c("clear text", "character <U C6C3>", "<e9>guret text"))
data$term <- trimws(gsub("<.*>", "", data$term))
  •  Tags:  
  • r
  • Related