s-news
[Top] [All Lists]

Re: transpose a data frame

To: Joe Cerniglia <cj5815@yahoo.com>
Subject: Re: transpose a data frame
From: John Fox <jfox@mcmaster.ca>
Date: Wed, 18 Feb 2004 16:10:57 -0500
Cc: s-news@wubios.wustl.edu
In-reply-to: <20040218204034.79336.qmail@web40505.mail.yahoo.com>
Dear Joe,

t() works on data frames, so all you need do is t(your.data.frame). Of course, this likely only makes sense if all of the columns of your.data.frame are numeric, and a numeric matrix will result. If you want the transpose to be a data frame, then you can do as.data.frame(t(your.data.frame)).

You can remove the column names from a data frame by names(my.data.frame) <- NULL, but that seems to me generally ill-advised.

I hope this helps,
 John

At 12:40 PM 2/18/2004 -0800, Joe Cerniglia wrote:
How can I transpose a data frame?

Can I strip the column names from a data frame?

Thanks.

Joe

-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox@mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------


<Prev in Thread] Current Thread [Next in Thread>