Skye                  package:MASS                  R Documentation

_A_F_M _C_o_m_p_o_s_i_t_i_o_n_s _o_f _A_p_h_y_r_i_c _S_k_y_e _L_a_v_a_s

_D_e_s_c_r_i_p_t_i_o_n:

     The 'Skye' data frame has 23 rows and 3 columns.

_U_s_a_g_e:

     Skye

_F_o_r_m_a_t:

     This data frame contains the following columns:

     '_A' Percentage of sodium and potassium oxides

     '_F' Percentage of iron oxide

     '_M' Percentage of magnesium oxide

_S_o_u_r_c_e:

     R. N. Thompson, J. Esson and A. C. Duncan (1972) Major element
     chemical variation in the Eocene lavas of the Isle of Skye. _J.
     Petrology_, *13*, 219-253.

_R_e_f_e_r_e_n_c_e_s:

     J. Aitchison (1986) _The Statistical Analysis of Compositional
     Data._ Chapman and Hall, p.360.

     Venables, W. N. and Ripley, B. D. (2002) _Modern Applied
     Statistics with S._ Fourth edition.  Springer.

_E_x_a_m_p_l_e_s:

     # ternary() is from the on-line answers.
     ternary <- function(X, pch = par("pch"), lcex = 1,
                         add = FALSE, ord = 1:3, ...)
     {
       X <- as.matrix(X)
       if(any(X) < 0) stop("X must be non-negative")
       s <- drop(X %*% rep(1, ncol(X)))
       if(any(s<=0)) stop("each row of X must have a positive sum")
       if(max(abs(s-1)) > 1e-6) {
         warning("row(s) of X will be rescaled")
         X <- X / s
       }
       X <- X[, ord]
       s3 <- sqrt(1/3)
       if(!add)
       {
         oldpty <- par("pty")
         on.exit(par(pty=oldpty))
         par(pty="s")
         plot(c(-s3, s3), c(0.5-s3, 0.5+s3), type="n", axes=FALSE,
              xlab="", ylab="")
         polygon(c(0, -s3, s3), c(1, 0, 0), density=0)
         lab <- NULL
         if(!is.null(dn <- dimnames(X))) lab <- dn[[2]]
         if(length(lab) < 3) lab <- as.character(1:3)
         eps <- 0.05 * lcex
         text(c(0, s3+eps*0.7, -s3-eps*0.7),
              c(1+eps, -0.1*eps, -0.1*eps), lab, cex=lcex)
       }
       points((X[,2] - X[,3])*s3, X[,1], ...)
     }

     ternary(Skye/100, ord=c(1,3,2))

