Re: [R] Creating a list by just using start and final component
Romain Francois wrote: Hollix wrote: Hi there, say, I have 100 matrices (m1,m2,...,m100) which I want to combine in a list. The list, thus, shall contain the matrices as components. Is it necessary to mention all 100 matrices in the list() command? I would like to use just the first and last matrix or something similar. Best, Holger Hi, you can do something like that: matrices - ls( pattern = m[0-9]+ ) res - lapply( matrices, get ) if you expect the items to be in an order like m1, m2, ..., m10, ..., m100 etc. rather than m1, m10, m100, ..., m2, ..., you'd rather res - lapply(matrices[order(nchar(matrices))], get) vQ __ 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.
[R] Creating a list by just using start and final component
Hi there, say, I have 100 matrices (m1,m2,...,m100) which I want to combine in a list. The list, thus, shall contain the matrices as components. Is it necessary to mention all 100 matrices in the list() command? I would like to use just the first and last matrix or something similar. Best, Holger -- View this message in context: http://www.nabble.com/Creating-a-list-by-just-using-start-and-final-component-tp23691673p23691673.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Creating a list by just using start and final component
Hollix wrote: Hi there, say, I have 100 matrices (m1,m2,...,m100) which I want to combine in a list. The list, thus, shall contain the matrices as components. Is it necessary to mention all 100 matrices in the list() command? I would like to use just the first and last matrix or something similar. Best, Holger Hi, you can do something like that: matrices - ls( pattern = m[0-9]+ ) res - lapply( matrices, get ) Romain -- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr __ 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.
Re: [R] Creating a list by just using start and final component
Wow, thank you so much! Where can I learn such creative approaches? Best, Holger Romain Francois-2 wrote: Hollix wrote: Hi there, say, I have 100 matrices (m1,m2,...,m100) which I want to combine in a list. The list, thus, shall contain the matrices as components. Is it necessary to mention all 100 matrices in the list() command? I would like to use just the first and last matrix or something similar. Best, Holger Hi, you can do something like that: matrices - ls( pattern = m[0-9]+ ) res - lapply( matrices, get ) Romain -- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr __ 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. -- View this message in context: http://www.nabble.com/Creating-a-list-by-just-using-start-and-final-component-tp23691673p23692141.html Sent from the R help mailing list archive at Nabble.com. __ 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.