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? Thanks in advance! Sincerely, Tord Sn?ll ----------------------------------------------------------------------- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi! On 04-Jan-02 Tord Snall wrote:> 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?Well, try unlist(), when you imported it as data.frame that should do the trick. At least my short test did so. ;-) So long, Winfried> > Thanks in advance! > > > Sincerely, > Tord Snäll > > > > ----------------------------------------------------------------------- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. > _---------------------------------- E-Mail: Winfried Theis <theis at statistik.uni-dortmund.de> Date: 04-Jan-02 Time: 14:13:51 Dipl.-Math. Winfried Theis, Fachbereich Statistik, Graduiertenkolleg "Angewandte Statistik" Universität Dortmund, 44221 Dortmund Tel.: +49-231-755-5903 FAX: +49-231-755-4387 ---------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Tord, At 02:32 PM 1/4/2002 +0100, Tord Snall wrote:>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?Matrices are stored column-wise, so try > mat <- rbind(c("a", "b", "c", "d"), c("e", "f", "g", "h"), c("i", "j", "k", "l")) > as.vector(t(mat)) [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" If you really want a one-column matrix, as your question seems to imply, you could use > matrix(t(mat), ncol=1) [,1] [1,] "a" [2,] "b" [3,] "c" [4,] "d" [5,] "e" [6,] "f" [7,] "g" [8,] "h" [9,] "i" [10,] "j" [11,] "k" [12,] "l" I hope that this helps, John ----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox ----------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I know how to plot a subset of a data.frame by doing something like > plot( mydata$x[y>2] ) Is there a way to do something similar for an entire data.frame? For example, I can do this something like > lm( x[y>2] ~ type[y>2], data=mydata ) but I'm a lazy typist, so I'd like to be able to do something like > lm( x ~ type, data=mydata[y>2] ) Is there a way to select rows from a data frame like that? Mike -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._