[R] how to make this sequence: 1,2,3,4,5,4,3,2,1
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Mar 7 15:21:10 CET 2010
On Sun, Mar 7, 2010 at 4:28 AM, Jim Lemon <jim at bitwrit.com.au> wrote:
> On 03/06/2010 09:35 AM, j verzani wrote:
>>
>> ...
>> Sorry about that one. On the errata page I have:
>>
>> page 16, exercise 1.12 #5
>> This one is most easily done using c() and the sequence operator :.
>> (Please
>> ignore request to use just seq and rep.)
>>
> And all over the world, perhaps even on other planets where anonymous R
> helpers lurk, the readers of the list can cease their trichotillomania and
> get a good night's sleep.
>
Thank goodness. Anyways freed from that constraint here is another solution:
pmin(1:9, 9:1)
This does not use c or rep but does use seq and pmin and has a certain
pleasing symmetry to it.
More information about the R-help
mailing list