wolfram@fischer-zim.ch
2003-Nov-24 12:41 UTC
[Rd] [R] lattice: ltext() does not accept NULL (PR#5290)
text( pos=NULL ) is working. ltext( pos=NULL ) gives an error message: "argument is of length zero" Wolfram
deepayan@stat.wisc.edu
2003-Nov-24 18:56 UTC
[Rd] [R] lattice: ltext() does not accept NULL (PR#5290)
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") }