Dear all, differing from the standard behaviour of 'format' the current (2.7.0) 'format.factor' destroys attributes like 'dim' and 'dimnames'. This unfortunately breaks some general code in the new package 'ff' for large file-based data which will support vectors and arrays of atomic and factors.
It would be nice if you could include the following fix in the next release of R. Kind regards Jens Oehlschlägel format.factor <- function (x, ...){ a <- attributes(x) a$class <- NULL a$levels <- NULL x <- as.character(x) attributes(x) <- a format(x, ...) } > x <- factor(c("aa",letters[-1])) > dim(x) <- c(13,2) > format(x, justify="right") [1] "aa" " b" " c" " d" " e" " f" " g" " h" " i" " j" " k" " l" " m" " n" " o" " p" " q" " r" " s" " t" " u" " v" " w" " x" " y" " z" > > format.factor <- + function (x, ...){ + a <- attributes(x) + a$class <- NULL + a$levels <- NULL + x <- as.character(x) + attributes(x) <- a + format(x, ...) + } > > format(x, justify="right") [,1] [,2] [1,] "aa" " n" [2,] " b" " o" [3,] " c" " p" [4,] " d" " q" [5,] " e" " r" [6,] " f" " s" [7,] " g" " t" [8,] " h" " u" [9,] " i" " v" [10,] " j" " w" [11,] " k" " x" [12,] " l" " y" [13,] " m" " z" > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 7.0 year 2008 month 04 day 22 svn rev 45424 language R version.string R version 2.7.0 (2008-04-22) -- ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel