From deepayan at stat.wisc.edu  Mon Nov 24 18:57:31 2003
From: deepayan at stat.wisc.edu (deepayan@stat.wisc.edu)
Date: Mon Nov 24 18:56:13 2003
Subject: [Rd] [R] lattice: ltext() does not accept NULL (PR#5290)
Message-ID: <20031124175731.C6A21F0C5@slim.kubism.ku.dk>

On Monday 24 November 2003 05:42, wolfram@fischer-zim.ch wrote:
> text( pos=NULL ) is working.
>
> ltext( pos=NULL ) gives an error message:
> 	"argument is of length zero"

The following should fix this :


ltext <-
    function(x, y = NULL, labels = seq(along = x),
             col = add.text$col,
             cex = add.text$cex,
             srt = 0,
             font = 1,
             adj = c(.5, .5),
             pos = NULL,
             ...)
{
    add.text <- trellis.par.get("add.text")
    xy <- xy.coords(x, y)
    if (!is.null(pos))
        adj <-
            if (pos == 1) c(.5, 1)
            else if (pos == 2) c(1, .5)
            else if (pos == 3) c(.5, 0)
            else if (pos == 4) c(0, .5)
            else stop("Invalid value of pos")
    if (length(adj) == 1) adj <- c(adj, .5)
    grid.text(label = labels, x = xy$x, y = xy$y,
              gp = gpar(col = col, font = font,
              fontsize = cex * trellis.par.get("fontsize")$default),
              just = c(if (adj[1] == 0) "left"
              else if (adj[1] == 1) c("right")
              else "centre",
              if (adj[2] == 0) "bottom"
              else if (adj[2] == 1) c("top")
              else "centre"),
              rot = srt,
              default.units = "native")
}


[Rd] [R] lattice: ltext() does not accept NULL (PR#5290)
deepayan@stat.wisc.edu