[R] placing labels in polygon center ?

Richard A. O'Keefe ok at cs.otago.ac.nz
Fri Aug 15 04:01:02 CEST 2003


Barry Rowlingson <B.Rowlingson at lancaster.ac.uk> wrote:
	Do you want:
	
	c(x[-1],x[1])  for a one-step 'rotation'?
	
That's just the kind of thing I did, except that it's ugly.
I've browsed src/main/subscript.c and got rather lost, but
it looks very much as though x[-1] starts by making a
logical vector c(FALSE,TRUE,...,TRUE) and then that's used
as an index to make a copy of (part of) x, then there's
x[1] (in general, x[1:n]) to be copied, and finally these
copies are pasted together.  That's 2 or 3 times as much
memory allocated as is actually kept; and it's pretty obvious
that it can be done in one quick pass with no redundant memory
allocation at the implementation level.

With rotation being so useful in APL, I rather expected that
there would be some C level implementation of rotate() or of
something better.  Note that rotate() should really have
three arguments:
    rotate(array, amount=1, axis=1)




More information about the R-help mailing list