try this: unlist(l) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O On 08/11/2007, Frank Schmid <fschmid@princeton.edu> wrote:> > Dear R user > > Suppose I have the following list: > > > f <- rnorm(2) > > s <- rnorm(3) > > l <- list(f,s) > > l > [[1]] > [1] 0.31784399 0.08575421 > > [[2]] > [1] -0.6191679 0.7615479 -1.0087659 > > > Can I stack the entries of this list in 1 vector with the first list > entry followed by the second? The reference manual says that I can use > the command /stack/, which can take as arguments either a list or a data > frame. But taking simply /stack(l)/ does not work, although it is a list. > > Many thanks for your hint > > Frank Schmid > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Frank Schmid wrote:>Dear R user > >Suppose I have the following list: > > > f <- rnorm(2) > > s <- rnorm(3) > > l <- list(f,s) > > l >[[1]] >[1] 0.31784399 0.08575421 > >[[2]] >[1] -0.6191679 0.7615479 -1.0087659 > > >Can I stack the entries of this list in 1 vector with the first list >entry followed by the second? The reference manual says that I can use >the command /stack/, which can take as arguments either a list or a data >frame. But taking simply /stack(l)/ does not work, although it is a list. > >Many thanks for your hint > >Frank Schmid > >______________________________________________ >R-help at r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. > > > >Hi, no need to use stack here: > l=list(a=1:4,b=5:8) > l $a [1] 1 2 3 4 $b [1] 5 6 7 8 > unlist(l) a1 a2 a3 a4 b1 b2 b3 b4 1 2 3 4 5 6 7 8 Regards, Thibaut. -- ###################################### Thibaut JOMBART CNRS UMR 5558 - Laboratoire de Biom?trie et Biologie Evolutive Universite Lyon 1 43 bd du 11 novembre 1918 69622 Villeurbanne Cedex T?l. : 04.72.43.29.35 Fax : 04.72.43.13.88 jombart at biomserv.univ-lyon1.fr http://lbbe.univ-lyon1.fr/-Jombart-Thibaut-.html?lang=en http://pbil.univ-lyon1.fr/software/adegenet/
Stack does not work for me either, but unlist works, i.e. unlist(l) --- Frank Schmid <fschmid at princeton.edu> wrote:> Dear R user > > Suppose I have the following list: > > > f <- rnorm(2) > > s <- rnorm(3) > > l <- list(f,s) > > l > [[1]] > [1] 0.31784399 0.08575421 > > [[2]] > [1] -0.6191679 0.7615479 -1.0087659 > > > Can I stack the entries of this list in 1 vector > with the first list > entry followed by the second? The reference manual > says that I can use > the command /stack/, which can take as arguments > either a list or a data > frame. But taking simply /stack(l)/ does not work, > although it is a list. > > Many thanks for your hint > > Frank Schmid > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. >
?unlist I think you're misreading ?stack. --- Frank Schmid <fschmid at princeton.edu> wrote:> Dear R user > > Suppose I have the following list: > > > f <- rnorm(2) > > s <- rnorm(3) > > l <- list(f,s) > > l > [[1]] > [1] 0.31784399 0.08575421 > > [[2]] > [1] -0.6191679 0.7615479 -1.0087659 > > > Can I stack the entries of this list in 1 vector > with the first list > entry followed by the second? The reference manual > says that I can use > the command /stack/, which can take as arguments > either a list or a data > frame. But taking simply /stack(l)/ does not work, > although it is a list. > > Many thanks for your hint > > Frank Schmid > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. >
Dear R user Suppose I have the following list: > f <- rnorm(2) > s <- rnorm(3) > l <- list(f,s) > l [[1]] [1] 0.31784399 0.08575421 [[2]] [1] -0.6191679 0.7615479 -1.0087659 Can I stack the entries of this list in 1 vector with the first list entry followed by the second? The reference manual says that I can use the command /stack/, which can take as arguments either a list or a data frame. But taking simply /stack(l)/ does not work, although it is a list. Many thanks for your hint Frank Schmid