Re: [R] Maintaining factors when copying from one data frame to another

From: Ferdinand Alimadhi <>
Date: Thu 08 Dec 2005 - 04:59:13 EST

newDF <- oldDF[,c("A","C","D")]

HTH Kurt Wollenberg wrote:

>Greetings all:
>OK, this is bugging the @#@%* out of me. I know the answer is simple
>and straightforward but for the life of me I cannot find it in the
>documentation, in the archives, or in my notes (because I know I've
>encountered this in the past). My problem is:
>I have a data frame with columns A, B, C, D, and E. A, B, and E are
>factors and C and D are numeric. I need a new data frame with just A,
>C, and D. When I copy these columns to a new data frame
>>newDF <- data.frame(cbind(oldDF$A, oldDF$C, oldDF$D))
>all the factor data comes out as levels rather than the original
>factors. How do I preserve the factors when I copy from one data frame
>to another?
>Thanks vary much,
>Kurt Wollenberg, Ph.D.
>Tufts Center for Vision Research
>Tufts-New England Medical Center
>750 Washington St #450
>Boston, MA 02111
>Office: 617-636-9028
>Fax: 617-636-8945
>email: kurt.wollenberg at gmail dot com
> mailing list
>PLEASE do read the posting guide!

Ferdinand Alimadhi
Programmer / Analyst
Harvard University
The Institute for Quantitative Social Science
(617) 496-0187

	[[alternative HTML version deleted]]

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Thu Dec 08 05:15:45 2005

This archive was generated by hypermail 2.1.8 : Thu 08 Dec 2005 - 09:31:27 EST