TITLE(strwidth @@ measure plotting width of character strings)
USAGE(
strwidth(s, units="user", cex=NULL)
)
ALIAS(strwidth)
ARGUMENTS(
ARG(s @@ character vector whose string widths in plotting units are to be
determined. ) 
ARG(units @@ character indicating in which units LANG(s) is measured; must be one of LANG("user"), LANG("figure"), LANG("inches").)
ARG(cex @@ character expansion to which is applies. Per default, the
current LANG(par("cex")) is used. )
)
DESCRIPTION(
The function computes the width of the given strings LANG(s[i]) on the
current plotting device in ITALIC(user) coordinates, ITALIC(inches) or as
fraction of the figure width LANG(par("fin")).
)
VALUE(
integer vector with the same length as LANG(s), giving the string width for
each LANG(s[i]).
)
SEEALSO(
LANG(LINK(text)), LANG(LINK(nchar))
)
EXAMPLES(
str.ex <- c("W","w","I",".","WwI.")
par(pty='s'); plot(1:100,1:100); par('usr')
sw <- strwidth(str.ex); sw
sum(sw[1:4] == sw[5])#- since the last string contains the others
sw / strwidth(str.ex, cex = .5) # between 1.5 & 4.2 (!),  font dependent..
BLANK
sw.i <- strwidth(str.ex, "inches"); 25.4 * sw.i#-- width in [mm]
unique(sw / sw.i)  #- constant factor: 1 value
mean(sw.i / strwidth(str.ex, "fig")) / par('fin')[1] # = 1: are the same
BLANK
##---- See how letters fall in classes -- depending on graphics device & font!
all.lett <- c(letters, LETTERS)
swL <- strwidth(all.lett)	 
swL <- 3 * swL / min(swL)
all(swL == round(swL))#- TRUE !
swL <- as.integer(swL)
n.classes <- length(tL <- table(swL)); tL
iL <- order(swL)
structure(swL[iL], names = all.lett[iL])
lett.classes <- structure(vector("list", n.classes), names= names(tL))
for(i in 1:n.classes)
  lett.classes[[i]] <- all.lett[swL == as.numeric(names(tL)[i])]
lett.classes
)
