Re: [Rd] (PR#9796) write.dcf/read.dcf cycle converts missing entry

From: Bill Dunlap <bill_at_insightful.com>
Date: Wed, 18 Jul 2007 16:32:04 -0700 (PDT)

On Wed, 18 Jul 2007 ripley_at_stats.ox.ac.uk wrote:

> I am seeing some problems here, for example when all the fields are
> missing, or all the fields in a row are missing. I've fixes for those,
> and will commit to R-devel shortly.

write.dcf() is also used by print.packageDesription() so this change affects how missing fields are printed there. In 2.5 we got

   > packageDescription("base", fields=c("Version","NoSuchField"))    Version: 2.5.0
   NoSuchField: NA

The missing trailing blank line is an inadvertant change (although it makes appending fields to a single record dcf file possible).

> > If you read a dcf file with read.dcf(file,fields=c("Field",...))
> > and the file does not contain the desired field "Field",
> > read.dcf puts a character NA for that entry in its output
> > matrix. If you then call write.dcf, passing it the output
> > of read.dcf(), it will write the entry "Field: NA". A subsequent
> > read.dcf() on write.dcf's output file will then have a "NA",
> > not a character NA, in the entry for "Field". I think that
> > write.dcf() should not write lines in the output file where
> > the input matrix contains a character NA.
> > ...
> > The diff would be
> > 19,22c19,24
> > < eor <- character(nr * nc)
> > < eor[seq.int(1, nr - 1) * nc] <- "\n"
> > < writeLines(paste(formatDL(rep.int(colnames(x), nr), c(t(x)),
> > < style = "list", width = width, indent = indent), eor,
> > ---
> >> tx <- t(x)
> >> not.na <- c(!is.na(tx))
> >> eor <- character(sum(not.na))
> >> eor[ c(diff(c(col(tx))[not.na]),0)==1 ] <- "\n"
> >> writeLines(paste(formatDL(rep.int(colnames(x), nr), c(tx),
> >> style = "list", width = width, indent = indent)[not.na], eor,

   [ The ==1 should be >=1 ]



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 19 Jul 2007 - 00:58:23 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 19 Jul 2007 - 12:37:00 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.