0

For example for a string like this

NANYANG-GIRLS'-HIGH-SCHOOL

how do I use gsub to replace ' to empty and make it

NANYANG-GIRLS-HIGH-SCHOOL

when I do it in R, it shows error

enter image description here

zx8754
  • 46,390
  • 10
  • 104
  • 180
Yanzi
  • 39
  • 5

1 Answers1

1

You can use either of the following two approaches:

sec_name <- gsub('\'', '', sec_name, fixed=TRUE)
sec_name <- gsub("'", "", sec_name, fixed=TRUE)

This first approach is a correct version of what you were doing. Here, we use single quotes for the strings, but we escape the single quote to make it a literal single quote.

AndrewGB
  • 12,571
  • 4
  • 13
  • 38
Tim Biegeleisen
  • 451,927
  • 24
  • 239
  • 318