Skip to content
Prev 208119 / 398502 Next

question about transpose

Hello,

Here are three examples.? I have a hunch you are looking for the last one.
?????? [,1] [,2] [,3]
First? "A"? "C"? "E"
Second "B"? "D"? "F"
???? First Second
[1,] "A"?? "B"
[2,] "C"?? "D"
[3,] "E"?? "F"
? [,1] [,2] [,3]
A "A"? "C"? "E"
B "B"? "D"? "F"
???? A?? B
[1,] "A" "B"
[2,] "C" "D"
[3,] "E" "F"


## My guess is that you are looking for this one.  What was in the
first column in the original matrix, is removed from the transposed
matrix and used as the column names
## "[,-1]" indicates everything but column 1
## ncol has to be specified because I used matrix() so I could include dimnames
## dimnames are set to be the contents of the first column of the
original matrix
???? [,1] [,2] [,3]
[1,] "a"? "c"? "e"
[2,] "b"? "d"? "f"
???? a?? b
[1,] "c" "d"
[2,] "e" "f"


HTH,


Joshua



On Fri, Jan 29, 2010 at 3:58 PM, Zoppoli, Gabriele (NIH/NCI) [G]
<zoppolig at mail.nih.gov> wrote:
--
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/