On Sun, 5 Feb 2023 15:13:54 -0500
Duncan Murdoch <murdoch.dun...@gmail.com> wrote:

<SNIP>
> 
> Just to build the mountain a little higher, I would use
> 
>    subset(p, seq_along(p) <= 20)
> 
> You should generally avoid expressions like "1:length(p)", because
> they don't do what you would expect in the unusual case that p is
> length 0.
> 
> Even in cases where you know p is not length 0, it's a good habit to
> get into so that in the future you don't get surprised.

Aaarrrggghhh.  That was a dumb-dumb on my part.  As Burns said to
Ripley (fortunes::fortune(26)), good catch.

Thanks.

cheers,

Rolf

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Stats. Dep't. phone: +64-9-373-7599 ext. 89622
Home phone: +64-9-480-4619

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to