Bug 16844 - write.csv without quotes when chr columns comes first and row.names = FALSE
Summary: write.csv without quotes when chr columns comes first and row.names = FALSE
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: I/O (show other bugs)
Version: R 3.2.4
Hardware: x86_64/x64/amd64 (64-bit) Windows 64-bit
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2016-04-18 14:42 UTC by Saulo
Modified: 2016-04-18 14:44 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Saulo 2016-04-18 14:42:21 UTC
Everything is ok when using row.names = TRUE
But, when row.names = FALSE, the first column comes entire without quotes, even in the column name.

> x <- data.frame(a=1:3, b= c('qq', 'ww', 'ee'), c=3:5)
> write.csv(x[,c('a', 'b', 'c')], 'test1.csv')
> write.csv(x[,c('b', 'a', 'c')], 'test2.csv')
> write.csv(x[,c('a', 'b', 'c')], 'test3.csv', row.names = FALSE)
> write.csv(x[,c('b', 'a', 'c')], 'test4.csv', row.names = FALSE)

The output files look like:

test1.csv - OK
,"a","b","c"
1,1,"qq",3
2,2,"ww",4
3,3,"ee",5

test2.csv - OK
,"b","a","c"
1,"qq",1,3
2,"ww",2,4
3,"ee",3,5

test3.csv - no quotes in first numeric column name
a,"b","c"
1,"qq",3
2,"ww",4
3,"ee",5

test4.csv - no qutoes in the entire first chr column
b,"a","c"
qq,1,3
ww,2,4
ee,3,5


> version
               _                           
platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          3                           
minor          2.4                         
year           2016                        
month          03                          
day            10                          
svn rev        70301                       
language       R                           
version.string R version 3.2.4 (2016-03-10)
nickname       Very Secure Dishes