Re: [R] as.data.frame(cbind()) transforming numeric to factor?

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sat 19 Aug 2006 - 01:11:55 EST

In "R version 2.4.0 Under development (unstable) (2006-08-08 r38825)" one can do this:

as.data.frame(cbind(x.1,x.2),stringsAsFactors = FALSE)

On 8/18/06, Tom Boonen <tom.boonen.maiden@gmail.com> wrote:
> Dear List,
>
> why does as.data.frame(cbind()) transform numeric variables to
> factors, once one of the other variablesused is a character vector?
>
> #
> x.1 <- rnorm(10)
> x.2 <- c(rep("Test",10))
> Foo <- as.data.frame(cbind(x.1))
> is.factor(Foo$x.1)
>
> Foo <- as.data.frame(cbind(x.1,x.2))
> is.factor(Foo$x.1)
> #
>
> I assume there is a good reason for this, can somebody explain? Thanks.
>
> Best,
> Tom
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Aug 19 01:24:06 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 19 Aug 2006 - 02:22:10 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.