[R] line up a matrix
Tord Snall
tord.snall at ebc.uu.se
Fri Jan 4 15:35:59 CET 2002
Dear Douglas Bates, Winfried Theis and Andy Liaw,
Thanks for your quick replies! All alternatives worked well of course.
One can keep on trying simple things for hours as a beginner (if you
happened to have forgotten...).
Tord Snäll
At 07:59 2002-01-04 -0600, you wrote:
>Tord Snall <tord.snall at ebc.uu.se> writes:
>
>> Dear all,
>>
>> I try to rearrange my ref. database (now in Excel!! :( ) for importing it
>> into a reference manager program (RIS format).
>>
>> My file basically look like this [3,4]-matrix:
>>
>> rbind(c("a", "b", "c", "d"), c("e", "f", "g", "h"), c("i", "j", "k", "l"))
>> [,1] [,2] [,3] [,4]
>> [1,] "a" "b" "c" "d"
>> [2,] "e" "f" "g" "h"
>> [3,] "i" "j" "k" "l"
>>
>> and I have tried to find a function to line up the matrix into a vector
>> which I would like to look like this:
>>
>> t(c("a", "b", "c", "d","e", "f", "g", "h","i", "j", "k", "l"))
>>
>> Is there any R function for available for that?
>
>In R matrices are stored in column major order so you want to transpose
>your matrix and convert it to a vector. One way is
>
> as.vector(t(mat))
>
>Interestingly using
>
> c(t(mat))
>
>which is almost symmetric with your t(c("a", ...)), would do the same
>thing.
>
>
>
-----------------------------------------------------------------------
Tord Snäll
Avd. f växtekologi, Evolutionsbiologiskt centrum, Uppsala universitet
Dept. of Plant Ecology, Evolutionary Biology Centre, Uppsala University
Villavägen 14
SE-752 36 Uppsala, Sweden
Tel: 018-471 28 82 (int +46 18 471 28 82) (work)
Tel: 018-25 71 33 (int +46 18 25 71 33) (home)
Fax: 018-55 34 19 (int +46 18 55 34 19) (work)
E-mail: Tord.Snall at ebc.uu.se
http://www.vaxtbio.uu.se/resfold/snall.htm
------------------------------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list