Skip to content
Back to formatted view

Raw Message

Message-ID: <E66794E69CFDE04D9A70842786030B9324FDDA@PA-MBX03.na.tibco.com>
Date: 2011-12-12T20:33:45Z
From: William Dunlap
Subject: Variables from a Dataframe
In-Reply-To: <CAM_vjun+69HW9bAQJbgf2DuVYxgfKJ=gsOXoK_LKYXzVHmdYpg@mail.gmail.com>

I would recommend using data.frame(var1, var2, ...)
and not cbind.data.frame(var1, var2, ...).  I consider
it bad form to directly call a method of a generic function.
Sometimes it leads to errors, as a method should be
free to assume that its inputs are of the class it
was declared to accept.   In the particular case of
cbind.data.frame, I think it just calls data.frame.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Sarah Goslee
> Sent: Monday, December 12, 2011 11:50 AM
> To: Jose Bustos Melo
> Cc: r-help at r-project.org
> Subject: Re: [R] Variables from a Dataframe
> 
> Without a reproducible example it's impossible to say for certain,
> but I'd try
> cbind.data.frame() instead of cbind().
> 
> You need to have a data frame, not a matrix, for the result.
> 
> Sarah
> 
> On Mon, Dec 12, 2011 at 2:44 PM, Jose Bustos Melo <jbustosmelo at yahoo.es> wrote:
> > Hello everyone,
> >
> > I want make a variable selection? from a dataframe, but when I build this new object (using cbind)
> the new table (which is a matrix) I lost all the original factor names in the variables. I get
> 1,2,3....
> >
> > Someone would be so kind and tell me if there's is a ny way to get variables in a dataframe, but not
> changing these factor to numbers?
> >
> > Thank you all.
> > Jos?
> 
> --
> Sarah Goslee
> http://www.functionaldiversity.org
> 
> ______________________________________________
> R-help at r-project.org 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.