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é [[alternative HTML version deleted]]
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
Dear Jose, Am Montag, den 12.12.2011, 19:44 +0000 schrieb Jose Bustos Melo:> 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?please provide a reproducible example as written in the posting guide. [?]> [[alternative HTML version deleted]]Read [1] to just send plain text messages. Thanks, Paul [1] http://email.about.com/od/yahoomailtips/qt/et_plain_text.htm -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111212/3332db2c/attachment.bin>
I'm glad that worked for you. It's a good idea to reply to the list, as well as me, so that there's public acknowledgment of a working solution, and so that the answer appears in the archives. Sarah On Mon, Dec 12, 2011 at 2:56 PM, Jose Bustos Melo <jbustosmelo at yahoo.es> wrote:> Thank you Sarah!!... that works well, thank you a lot!!!.... Always I get so > upset when I get stuck with some code. > > have a good day! > Jos? > > ________________________________ > De: Sarah Goslee <sarah.goslee at gmail.com> > Para: Jose Bustos Melo <jbustosmelo at yahoo.es> > CC: "r-help at r-project.org" <r-help at r-project.org> > Enviado: lunes 12 de diciembre de 2011 16:50 > Asunto: 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? > > --