[Bioc-devel] Use DataFrame's printing format for data.frames
Ryan C. Thompson
rct at thompsonclan.org
Sun Nov 18 03:01:45 CET 2012
Actually, my previous post had a small bug in it: it would throw an
error when printing a zero-column data frame. The following code fixes this:
print.data.frame <- function(df) {
if (ncol(df) > 0 && require("IRanges")) {
prev.max.print <- getOption("max.print")
on.exit(options(max.print=prev.max.print))
options(max.print=ncol(df) * 20)
x <- capture.output(print(as(df, "DataFrame")))
cat(str_replace(x[[1]], "DataFrame", "data frame"),
x[-1],
sep="\n")
} else {
base::print.data.frame(df)
}
}
More information about the Bioc-devel
mailing list