问题
My dataframe in R has a column A where I have string data with single quote in it.
Column A
'Hello World'
'Hi World'
'Good morning world'
What I would like to do is to replace the single quote with double quotes and achieve the output like below.
Column A
"Hello World"
"Hi World"
"Good morning world
Can this be achieved? Thank you in advance for reading.
回答1:
Try this:
"iris" is a sample data frame and I am trying to replace single quotes of "Species" column. Since ' and " are special characters within strings hence they are specified using escape sequences:
iris$Species <- gsub("\'","\"", iris$Species)
来源:https://stackoverflow.com/questions/44298123/replace-single-quote-with-double-quote-in-a-column-in-r