R/egg.plot.R

#' Plot the fitted egg object
#'
#' Adds the fitted egg object to the current plot window
#'
#' @param egg an object of class \code{egg.fit}
#' @param ... additional parameters passed to the \code{\link[graphics]{lines}} function
#'
#' @return None
#'
#' @examples
#' stop()
#'
#' @export
egg.plot = function(egg, ...) {
  Rinv = solve(egg$R)
  n = 100
  qq = matrix(0, nrow=2*n, ncol=2)
  qq[,2] = c(seq(-egg$length/2, egg$length/2, length.out=n), -seq(-egg$length/2, egg$length/2, length.out=n))
  z.hat = normalise(qq[,2], -egg$length/2, egg$length/2, 0, 1)
  for(i in 1:(2*n)) {
    qq[i,1] = get.d(z.hat[i], egg)
    if(i > n) {
      qq[i,1] = -qq[i,1]
    }
    qq[i,] = t(Rinv %*% cbind(c(qq[i,1], qq[i,2]))) + egg$mid.point
  }
  lines(qq[,1], qq[,2], ...)
}

Try the eggs package in your browser

Any scripts or data that you put into this service are public.

eggs documentation built on May 2, 2019, 5:23 p.m.