From h.wickham at gmail.com  Mon Nov 17 14:10:10 2008
From: h.wickham at gmail.com (hadley wickham)
Date: Mon, 17 Nov 2008 07:10:10 -0600
Subject: [Rd] stringsAsFactors = FALSE
Message-ID: <f8e6ff050811170510i576d0014qdb22f08c57690bb2@mail.gmail.com>

Hi all,

I love the option to not automatically convert strings into factors,
but there are three places that the current option doesn't work where
I think it should:

options(stringsAsFactors = FALSE)

str(expand.grid(letters))
str(type.convert(letters))

df <- read.fwf(textConnection(paste(letters,collapse="\n")), 1)
str(df)

I think type.convert and read.fwf can be fixed by giving them a
stringsAsFactors argument and then using asis = !stringsAsFactors
(like read.table).  The key lines in expand.grid would seem to be

            if (!is.factor(x) && is.character(x))
                x <- factor(x, levels = unique(x))

but I'm not sure why they are being converted to factors in the first place.

Regards,

Hadley

-- 
http://had.co.nz/



[Rd] stringsAsFactors = FALSE
hadley wickham