Re: [R] seq_len and loops

2014-01-02 Thread Göran Broström
] On Behalf Of Göran Broström Sent: Tuesday, December 31, 2013 4:10 PM To: r-help@R-project.org Subject: Re: [R] seq_len and loops Thanks for the answers from Duncan, Bill, Gabor, and Henrik. You convinced me that 1. The solution if (x 1){ for (x in 2:x){ ... is the easiest, most effective

Re: [R] seq_len and loops

2014-01-01 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Göran Broström Sent: Tuesday, December 31, 2013 4:10 PM To: r-help@R-project.org Subject: Re: [R] seq_len and loops Thanks for the answers from Duncan, Bill, Gabor

Re: [R] seq_len and loops

2013-12-31 Thread Göran Broström
] On Behalf Of Duncan Murdoch Sent: Saturday, December 21, 2013 3:52 PM To: Göran Broström; R-help@r-project.org Subject: Re: [R] seq_len and loops On 13-12-21 6:50 PM, Duncan Murdoch wrote: On 13-12-21 5:57 PM, Göran Broström wrote: I was recently reminded on this list that Using 1:ncol() is bad

Re: [R] seq_len and loops

2013-12-22 Thread William Dunlap
[mailto:r-help-boun...@r-project.org] On Behalf Of Duncan Murdoch Sent: Saturday, December 21, 2013 3:52 PM To: Göran Broström; R-help@r-project.org Subject: Re: [R] seq_len and loops On 13-12-21 6:50 PM, Duncan Murdoch wrote: On 13-12-21 5:57 PM, Göran Broström wrote: I was recently

[R] seq_len and loops

2013-12-21 Thread Göran Broström
I was recently reminded on this list that Using 1:ncol() is bad practice (seq_len is designed for that purpose) (Ripley) This triggers the following question: What is good practice for 2:ncol(x)? (This is not a joke; in a recursive situation it often makes sense to perform the calculation

Re: [R] seq_len and loops

2013-12-21 Thread Duncan Murdoch
On 13-12-21 5:57 PM, Göran Broström wrote: I was recently reminded on this list that Using 1:ncol() is bad practice (seq_len is designed for that purpose) (Ripley) This triggers the following question: What is good practice for 2:ncol(x)? (This is not a joke; in a recursive situation it often

Re: [R] seq_len and loops

2013-12-21 Thread Duncan Murdoch
On 13-12-21 6:50 PM, Duncan Murdoch wrote: On 13-12-21 5:57 PM, Göran Broström wrote: I was recently reminded on this list that Using 1:ncol() is bad practice (seq_len is designed for that purpose) (Ripley) This triggers the following question: What is good practice for 2:ncol(x)? (This is

Re: [R] seq_len and loops

2013-12-21 Thread Henrik Bengtsson
What about seq_len2 - function(length.out, from=1L) { seq(from=from, length.out=max(0L, length.out-from+1L)) } lapply(0:4, FUN=seq_len2, from=2L) [[1]] integer(0) [[2]] integer(0) [[3]] [1] 2 [[4]] [1] 2 3 [[5]] [1] 2 3 4 /Henrik On Sat, Dec 21, 2013 at 2:57 PM, Göran Broström