Re: [R] create sequences from two from and to vectors
one way is using mapply(), e.g., mapply(:, 1:4, 3:6) I hope it helps. Best, Dimitris Yasir Kaheil wrote: hi all, how can I create sequences that start from a known vector, say x1 and end with another say x2- also suppose all the sequences will be the same length. I don't want to use a for loop x1-c(1,2,3,4); x2-(3,4,5,6); what I want is 1 2 3 4 2 3 4 5 3 4 5 6 Thanks - Yasir H. Kaheil Columbia University -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ 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] create sequences from two from and to vectors
on 01/09/2009 02:42 PM Yasir Kaheil wrote: hi all, how can I create sequences that start from a known vector, say x1 and end with another say x2- also suppose all the sequences will be the same length. I don't want to use a for loop x1-c(1,2,3,4); x2-(3,4,5,6); what I want is 1 2 3 4 2 3 4 5 3 4 5 6 Thanks mapply(seq, x1, x2) [,1] [,2] [,3] [,4] [1,]1234 [2,]2345 [3,]3456 See ?mapply HTH, Marc Schwartz __ 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] create sequences from two from and to vectors
Great! thank you so much! Dimitris Rizopoulos-4 wrote: one way is using mapply(), e.g., mapply(:, 1:4, 3:6) I hope it helps. Best, Dimitris Yasir Kaheil wrote: hi all, how can I create sequences that start from a known vector, say x1 and end with another say x2- also suppose all the sequences will be the same length. I don't want to use a for loop x1-c(1,2,3,4); x2-(3,4,5,6); what I want is 1 2 3 4 2 3 4 5 3 4 5 6 Thanks - Yasir H. Kaheil Columbia University -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ 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. - Yasir H. Kaheil Columbia University -- View this message in context: http://www.nabble.com/create-sequences-from-two-%22from%22-and-%22to%22-vectors-tp21380194p21380311.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] create sequences from two from and to vectors
Try: mapply( seq, from=1:4, to=7:10 ) [,1] [,2] [,3] [,4] [1,]1234 [2,]2345 [3,]3456 [4,]4567 [5,]5678 [6,]6789 [7,]789 10 Is that what you want? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Yasir Kaheil Sent: Friday, January 09, 2009 1:43 PM To: r-help@r-project.org Subject: [R] create sequences from two from and to vectors hi all, how can I create sequences that start from a known vector, say x1 and end with another say x2- also suppose all the sequences will be the same length. I don't want to use a for loop x1-c(1,2,3,4); x2-(3,4,5,6); what I want is 1 2 3 4 2 3 4 5 3 4 5 6 Thanks - Yasir H. Kaheil Columbia University -- View this message in context: http://www.nabble.com/create-sequences- from-two-%22from%22-and-%22to%22-vectors-tp21380194p21380194.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. __ 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.