How to remove single quote from a string in R?

quotes, r

Solution

To replace text, use (`g`)`sub`:

result <- gsub("'", '', yourString)

The function is vectorised so you can apply it directly to your data frame without the need for a loop or an `apply`:

df$X2 <- gsub("'", '', df$X2)

Problem

In a data frame I have text like ``` "X1" "X2" "1" 53 "'all.downtown@enron.com'" "2" 54 "'all.enron-worldwide@enron.com'" "3" 55 "'all.worldwide@enron.com'" "4" 56 "'all_enron_north.america@enron.com'" ``` How do I remove the single quotes from the string in 2nd column?

Original source