Skip to content
Prev 132419 / 398506 Next

Factor Madness

Whoops, it looks like there's a typo in ?cbind (R version 2.6.0 Patched 
(2007-10-11 r43143)), and I blindly copied it into my message.

That should read (emphasis added):

"and convert character columns to factors unless stringsAsFactors = 
***FALSE***"

Here's an example:

 > x <- data.frame(X=1:3)
 > sapply(cbind(x, letters[1:3]), class)
            X letters[1:3]
    "integer"     "factor"
 > sapply(cbind(x, letters[1:3], stringsAsFactors=FALSE), class)
            X letters[1:3]
    "integer"  "character"
 >

Thanks to Mark Leeds for pointing that out to me in a private message!

(I see this still in the source at 
https://svn.r-project.org/R/trunk/src/library/base/man/cbind.Rd -- is that 
the right place to look for the latest source to make sure it hasn't been 
fixed already?)

-- Tony Plate
Tony Plate wrote: