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
  • 52,746
  • 12
  • 114
  • 209
Yanzi
  • 39
  • 6

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
  • 16,126
  • 5
  • 18
  • 49
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360