On Fri, 18 Aug 2006, Tom Boonen 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.
Only if you can explain the good reason why you did not just use data.frame(x.1, x.2)! cbind() makes a matrix out of vectors, here a character matrix. And then as.data.frame() converts character columns to factors. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ 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.