[Rd] print.data.frame curiosity

Romain Francois romain at r-enthusiasts.com
Thu May 6 09:26:27 CEST 2010


Hello,

I made a mistake and passed stringsAsFactors to the wrong function in :

 > df <- as.data.frame( list( x = 1:3, y = c("a", "b", "c" ), 
stringsAsFactors = FALSE ) )

But then :

 > df
   x y
1 1 a
2 2 b
3 3 c

and :

 > df[["y"]]
[1] a b c
Levels: a b c
 > str( df )
'data.frame':	3 obs. of  3 variables:
  $ x               : int  1 2 3
  $ y               : Factor w/ 3 levels "a","b","c": 1 2 3
  $ stringsAsFactors: logi  FALSE FALSE FALSE


Somehow, print.data.frame does not want to print a column named 
"stringsAsFactors". (I know this is a bad name for a column, but ...)

Apparently, this line in format.data.frame is responsible for the mismatch:

x <- do.call("data.frame", rval)

Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9aKDM9 : embed images in Rd documents
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7



More information about the R-devel mailing list