Skip to content
Prev 18600 / 63424 Next

write.csv ignores 'row.names'

Upon replying to this email, I took a look at 'write.csv()' and noticed 
something interesting.  I remember there being a discussion sometime in 
the past about letting 'write.csv()' accept the 'row.names' argument. 
However, I get the following error:

 > write.csv(airquality, file = "myfile.csv", row.names = F)
Error in write.table(airquality, file = "myfile.csv", row.names = F, 
col.names = NA,  :
         col.names = NA makes no sense when row.names = FALSE
 >

In 'write.csv()' there is

     rn <- Call$row.names
     Call$col.names <- if (is.logical(rn) && !rn)
         TRUE

but is.logical(rn) is always FALSE because even if 'row.names' is 
specified (non-NULL), it is of class "name".  Perhaps something like

rn <- eval(Call$row.names)

would suffice?  I can't tell if that would break anything.

-roger
Sven Schaltenbrand wrote:
Message-ID: <4385EABA.7070704@jhsph.edu>
In-Reply-To: <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAhSZy0zcp30KH/pKqSCi9sMKAAAAQAAAAcIeg/3SLt0iaHwGiAYoTZgEAAAAA@schaltenbrand.de>