[R-sig-DB] character to factor transform in package RpgSQL
Seth Falcon
@eth @end|ng |rom u@erpr|m@ry@net
Sun Nov 14 05:52:17 CET 2010
Hi,
On Sat, Nov 13, 2010 at 8:28 PM, Xiaobo Gu <guxiaobo1982 using gmail.com> wrote:
> Hi,
> I have looked at the source code of package RpgSQL, it seems the fetch
> function does not transform character column into factors, but when I
> use the class function to test the result data frame of function
> fetch, it all tells factor, can you help identify which part of the
> function doing the transformation, in our usage we want to keep some
> character column just as characters, bellowing is the source code of
> function fetch in package RpgSQL.
A guess is that you are seeing the default behavior of data.frame (and
likely also as.data.frame) in transforming character vectors into
factors.
So I would suggest experimenting with this last bit:
> if (j)
> as.data.frame(l, row.names=1:j)
> else
> as.data.frame(l)
> })
For example:
> sapply(as.data.frame(letters[1:3]), class)
letters[1:3]
"factor"
> sapply(as.data.frame(letters[1:3], stringsAsFactors=FALSE), class)
letters[1:3]
"character"
+ seth
--
Seth Falcon | @sfalcon | http://userprimary.net/
More information about the R-sig-DB
mailing list