From p.dalgaard at biostat.ku.dk  Thu Nov 24 18:02:13 2005
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: 24 Nov 2005 18:02:13 +0100
Subject: [Rd] write.csv ignores 'row.names'
In-Reply-To: <4385EC20.6020000@jhsph.edu>
References: <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAhSZy0zcp30KH/pKqSCi9sMKAAAAQAAAAcIeg/3SLt0iaHwGiAYoTZgEAAAAA@schaltenbrand.de>
	<4385EABA.7070704@jhsph.edu> <4385EC20.6020000@jhsph.edu>
Message-ID: <x264qif08a.fsf@viggo.kubism.ku.dk>

Roger Peng <rpeng at jhsph.edu> writes:

> Okay, upon further examination, it appears that it works fine if you set 
> 'row.names = FALSE' as opposed to 'row.names = F'.

Nope. It's still a bug and you're quite right that eval() is needed.
We can't have that an argument only works when supplied as an explicit
constant. 

 
> -roger
> 
> Roger Peng wrote:
> > 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:
> > 
> >> hallo,
> >>  
> >> i have a problem by writing a csv file
> >> the first colum is filled with index numbers from 1 to n.
> >> i have to unique two csv files once a week while one file is always the
> >> same.
> >> can anybody tell me, how to write the dataset into a csv file without the
> >> first row of the indexnumbers.
> >> x[,-1] does not wok as it eliminates the first "interesting" colum.
> >> col.names is not accepted by r (do i habe to start a package first? which
> >> one?)
> >>  
> >> thx
> >>  
> >> sven
> >>
> >>     [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> R-devel at r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-devel
> >>
> >
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 

-- 
   O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



[Rd] write.csv ignores 'row.names'
Peter Dalgaard