Re: [R] seq_len and loops

2014-01-02 Thread Göran Broström
tibco.com -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, and Henrik. Y

Re: [R] seq_len and loops

2014-01-01 Thread William Dunlap
h clauses make objects with the same names and types? I mildly prefer avoiding if statements because it makes reasoning about the results of the code more complicated. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mail

Re: [R] seq_len and loops

2013-12-31 Thread Göran Broström
.@r-project.org [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 rec

Re: [R] seq_len and loops

2013-12-22 Thread William Dunlap
-Original Message- > From: r-help-boun...@r-project.org [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

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 wrote: > I

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 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 oft

[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 calculatio

Re: [R] seq_len

2007-12-09 Thread Joe W. Byers
Charilaos Skiadas wrote: > > On Dec 8, 2007, at 1:02 AM, Joe W. Byers wrote: > >> In a post on R-devel, Prof Ripley add the following comment >> | > BTW, 1:dim(names)[1] is dangerous: it could be 1:0. That was the >> | > motivation for seq_len. >> >> I use the dim(names)[1] and dim(x)[2] along wit

Re: [R] seq_len

2007-12-08 Thread Charilaos Skiadas
On Dec 8, 2007, at 1:02 AM, Joe W. Byers wrote: > In a post on R-devel, Prof Ripley add the following comment > | > BTW, 1:dim(names)[1] is dangerous: it could be 1:0. That was the > | > motivation for seq_len. > > I use the dim(names)[1] and dim(x)[2] along with length(x) with > varying > lev

[R] seq_len

2007-12-07 Thread Joe W. Byers
In a post on R-devel, Prof Ripley add the following comment | > BTW, 1:dim(names)[1] is dangerous: it could be 1:0. That was the | > motivation for seq_len. I use the dim(names)[1] and dim(x)[2] along with length(x) with varying levels of frustration depending on the object which I am trying to