Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove quotes ("") from a data.frame in R

Tags:

r

I have a data.frame with several columns, all of them are character class. All values are in double quotes, I would like to remove those quotes.

Example

df1      df2
"1203"   "Name1"
"2304"   "Name2"
like image 329
BigDataScientist Avatar asked Jan 24 '14 16:01

BigDataScientist


People also ask

How do I paste without quotation marks in R?

noquote() function in R Language is used to prints strings without quotes.

How do you replace quotes in R?

Just use "\"" or '"' to match a single double quote.


1 Answers

The print() method for data frames has an option quote=, which you can set to FALSE:

print.data.frame(data.frame(x=c("Hello", "World")), 
                 quote=FALSE)
#       x
# 1 Hello
# 2 World

See also ?print.data.frame(= help)

Edit:

With regards to the dputed data in the comment below:

as.data.frame(sapply(df, function(x) gsub("\"", "", x)))
like image 53
lukeA Avatar answered Sep 19 '22 06:09

lukeA