| Qrot | R Documentation | 
Construct the p \times p rotation matrix that rotates the
unit vector (1,0,....0), i.e., the x_1-axis,
onto (1,1,1,...1)/\sqrt{p}, or more generally to
u/{\left\|u\right\|}  (u :=unit.image).
Qrot(p, transpose = FALSE, unit.image = rep(1, p))
p | 
 integer; the dimension (of the vectors involved).  | 
transpose | 
 logical indicating if the transposed matrix is to returned.  | 
unit.image | 
 numeric vector of length   | 
The qr decomposition is used for a Gram-Schmitt basis
orthogonalization.
p \times p orthogonal matrix which rotates
(1,0,...,0) onto a vector proportional to unit.image.
Martin Maechler
qr, matrix (and vector) multiplication,
%*%.
Q <- Qrot(6)
zapsmall(crossprod(Q)) # 6 x 6 unity <==> Q'Q = I  <==> Q orthogonal
if(require("MASS")) {
  Qt <- Qrot(6, transpose = TRUE)
  stopifnot(all.equal(Qt, t(Q)))
  fractions(Qt ^2) # --> 1/6  1/30  etc, in an almost lower-triagonal matrix
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.