I went in and cleaned a lot of this up. We now no longer coerce strings to
factors when coercing a DataFrame to data.frame, nor do we check column
names.

Version: 1.19.25


On Tue, Aug 20, 2013 at 11:18 AM, Murat Tasan <mmuurr@gmail.com> wrote:

> hi all -- does anyone know how to turn off the forced conversion of
> character vectors to factors when merging with IRanges::DataFrame
> objects?
> in the example below fooX.df is a base data.frame, while fooX.DF is
> the IRanges::DataFrame equivalent.
>
> example:
>
> > foo1.df <- data.frame(a = letters[1:10], b = runif(10), stringsAsFactors
> = FALSE); foo1.DF <- DataFrame(foo1.df)
> > foo2.df <- data.frame(a = letters[1:10], c = -runif(10),
> stringsAsFactors = FALSE); foo2.DF <- DataFrame(foo2.df)
> > foo3.df <- merge(foo1.df, foo2.df); foo3.DF <- merge(foo1.DF, foo2.DF)
> > sapply(foo3.df, class); foo3.df
>           a           b           c
> "character"   "numeric"   "numeric"
>    a         b           c
> 1  a 0.4112609 -0.64623114
> 2  b 0.5656937 -0.88098189
> 3  c 0.4682333 -0.26826974
> 4  d 0.1374115 -0.05801876
> 5  e 0.3506727 -0.23886691
> 6  f 0.5035583 -0.14777341
> 7  g 0.6833072 -0.09146686
> 8  h 0.7256269 -0.20445511
> 9  i 0.9553401 -0.76399925
> 10 j 0.3809191 -0.66888397
> > sapply(foo3.DF, class); foo3.DF
>         a         b         c
>  "factor" "numeric" "numeric"
> DataFrame with 10 rows and 3 columns
>           a         b           c
>    <factor> <numeric>   <numeric>
> 1         a 0.4112609 -0.64623114
> 2         b 0.5656937 -0.88098189
> 3         c 0.4682333 -0.26826974
> 4         d 0.1374115 -0.05801876
> 5         e 0.3506727 -0.23886691
> 6         f 0.5035583 -0.14777341
> 7         g 0.6833072 -0.09146686
> 8         h 0.7256269 -0.20445511
> 9         i 0.9553401 -0.76399925
> 10        j 0.3809191 -0.66888397
>
>
> i've tried adding the "stringsAsFactors = FALSE" into the merge(...)
> calls, thinking perhaps that switch is forwarded to an underlying
> data.frame(...) call, but that doesn't seem to the be the case (as "a"
> is still converted to a factor).
> i'd also rather not turn off the global stringsAsFactors behavior, as
> i want to ensure my script runs properly on others' R setups without
> having to modify their state.
>
> thanks for any help!
>
> -murat
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor@r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>

	[[alternative HTML version deleted]]

