Peng Peng
Peng Peng

Reputation: 1365

Can the quote argument in write.table() only use double quotation marks?

In the write.table() function in R, is it possible to supply the quote argument with a character to use in place of the standard double quotes (")?

e.g. an attempt to supply single quote ' as argument:

  name sex age height
1   x1   F  18    162
2   x2   M  19    170
3   x3   M  21    178
4   x4   F  22    166
5   x5   F  23    165

write.table('test',data,sep=',',row.names=F,quote="\'")  

which returns:

Error in write.table("test", data, sep = ",", row.names = F, quote = "\'") : invalid 'quote' specification

Upvotes: 0

Views: 10461

Answers (1)

Peng Peng
Peng Peng

Reputation: 1365

i get it .

  1. quote=T,every column data will be surrounded by double quotes.
  2. quote=F,every column data will not be surrounded by double quotes.
  3. quote=vector,such as fellowing:

    write.table(file='test',data,sep=',',row.names=F,quote=c(1,2))

the column 1,column 2 will be surrounded by double quotes.

Upvotes: 4

Related Questions