| To: | Joe Cerniglia <cj5815@yahoo.com> |
|---|---|
| Subject: | Re: transpose a data frame |
| From: | Sundar Dorai-Raj <sundar.dorai-raj@PDF.COM> |
| Date: | Wed, 18 Feb 2004 14:55:09 -0600 |
| Cc: | s-news@wubios.wustl.edu |
| In-reply-to: | <20040218204034.79336.qmail@web40505.mail.yahoo.com> |
| Organization: | PDF Solutions, Inc. |
| References: | <20040218204034.79336.qmail@web40505.mail.yahoo.com> |
| Reply-to: | sundar.dorai-raj@PDF.COM |
| User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) |
Joe Cerniglia wrote: How can I transpose a data frame?
Yes, but be careful:
> y <- data.frame(A = 1:4, B = 2:5)
> z <- t(y)
> data.class(z)
[1] "matrix"
> z
1 2 3 4
A 1 2 3 4
B 2 3 4 5
> y <- data.frame(A = 1:4, B = 2:5, C = letters[1:4])
> z <- t(y)
> data.class(z)
[1] "matrix"
> z
1 2 3 4
A "1" "2" "3" "4"
B "2" "3" "4" "5"
C "a" "b" "c" "d"
> Can I strip the column names from a data frame?
>
> Thanks.
>
> Joe
Depends on what you mean by "strip". names(data) will return the column
names.
HTH, Sundar |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | transpose a data frame, Joe Cerniglia |
|---|---|
| Next by Date: | Re: transpose a data frame, John Fox |
| Previous by Thread: | transpose a data frame, Joe Cerniglia |
| Next by Thread: | Re: transpose a data frame, John Fox |
| Indexes: | [Date] [Thread] [Top] [All Lists] |