# [R] placing labels in polygon center ?

Liaw, Andy andy_liaw at merck.com
Thu Aug 14 14:15:32 CEST 2003

```This is rather simple-minded:

rot <- function(x, k=1) {
k <- k %% length(x)
x[c((k+1):length(x), 1:k)]
}

Andy

> -----Original Message-----
> From: Richard A. O'Keefe [mailto:ok at cs.otago.ac.nz]
> Sent: Thursday, August 14, 2003 1:28 AM
> To: r-help at stat.math.ethz.ch
> Subject: Re: [R] placing labels in polygon center ?
>
>
> I wrote:
> 	I found myself wishing for a function to rotate a vector.
> 	Is there one?  I know about ?lag, but help.search("rotate")
> 	didn't find anything to the point.
>
> Here I was regarding a vector as a _sequence_.
> The (one-step) rotation of c(u,v,w,x,y,z) is c(v,w,x,y,z,u).
> This is pretty much the way APL uses the word "rotate" (the
> vertical-bar-overstruck-with-a-circle operator).
>
> Spencer Graves <spencer.graves at PDF.COM> replied:
> 	I didn't study your code, but regarding a function to rotate a
> 	vector:  Multiplication by an orthogonal matrix does that.
>
> This is a misunderstanding.  We were both using the word
> "rotate" in a standard way, the problem is that it has more
> than one "standard" meaning.
>
> As a matter of fact,
> 	/ 0 1 0 0 \  / u \     / v \
> 	| 0 0 1 0 |  | v |     | w |
> 	| 0 0 0 1 |  | w |  =  | x |
> 	\ 1 0 0 0 /  \ x /     \ u /
> so you *can* do the kind of rotation I want using a matrix
> multiplication, and this is mathematically useful; it's just
> not a very good way to do it in a computer.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo> /r-help
>

------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA), and/or
its affiliates (which may be known outside the United States as Merck Frosst,
Merck Sharp & Dohme or MSD) that may be confidential, proprietary copyrighted
and/or legally privileged, and is intended solely for the use of the
individual or entity named on this message.  If you are not the intended