在R中的列中用双引号替换单引号

Replace single quote with double quote in a column in R

我在 R 中的数据框有一个 A 列,其中我有带单引号的字符串数据。

Column A
'Hello World'
'Hi World'
'Good morning world'

我想做的是用双引号替换单引号并实现如下输出。

Column A
"Hello World"
"Hi World"
"Good morning world

这能实现吗? 预先感谢您的阅读。

试试这个:

"iris" 是一个示例数据框,我正在尝试替换 "Species" 列的单引号。由于 ' 和 " 是字符串中的特殊字符,因此使用转义序列指定它们:

iris$Species <- gsub("\'","\"", iris$Species)