There might be a minor typographical error in the documentation of the function strwidth, namely, from
?strwidth
we get:
"Note that the ?height? of a string is determined only by the number of linefeeds ("\n") it contains: it is the (number of linefeeds - 1) times the line spacing plus the height of "M" in the selected font. (...)"
I think the correct phrasing should be:
"Note that the ?height? of a string is determined only by the number of linefeeds ("\n") it contains: it is the (number of linefeeds) times the line spacing plus the (number of linefeeds + 1) times the height of "M" in the selected font. (...)"
Alberto Monteiro
Typographical error in the documentation of function strwidth?
4 messages · ALBERTO VIEIRA FERREIRA MONTEIRO, Peter Dalgaard
I don't think so. I'll give you that it should either be the (number of lines - 1)*spacing or (number of linefeeds)*spacing, but it's correct to count the height of "M" only on the top line. -pd It is correct as written
On 16 Mar 2016, at 22:39 , ALBERTO VIEIRA FERREIRA MONTEIRO <albmont at centroin.com.br> wrote:
There might be a minor typographical error in the documentation of the function strwidth, namely, from
?strwidth
we get:
"Note that the ?height? of a string is determined only by the number of linefeeds ("\n") it contains: it is the (number of linefeeds - 1) times the line spacing plus the height of "M" in the selected font. (...)"
I think the correct phrasing should be:
"Note that the ?height? of a string is determined only by the number of linefeeds ("\n") it contains: it is the (number of linefeeds) times the line spacing plus the (number of linefeeds + 1) times the height of "M" in the selected font. (...)"
Alberto Monteiro
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
Peter Dalgaard wrote:
I don't think so. I'll give you that it should either be the (number of lines - 1)*spacing or (number of linefeeds)*spacing, but it's correct to count the height of "M" only on the top line. -pd It is correct as written
Ah, ok, I see now. The "line spacing" is not the line spacing, but the inter-line spacing plus
the height of "M":
"Note that the ?height? of a string is determined only by the number of linefeeds ("\n") it contains: it is the (number of linefeeds - 1) times the line spacing plus the height of "M" in the selected font. For an expression it is the height of the bounding box as computed by plotmath. Thus in both cases it is an estimate of how far above the final baseline the typeset object extends. (It may also extend below the baseline.) The inter-line spacing is controlled by cex, par("lheight") and the ?point size? (but not the actual font in use)"
It's still confusing... Specially since there's no way to get the inter-line spacing except by running
strheight("M\nM") - 2 * strheight("M")
Alberto Monteiro
On 17 Mar 2016, at 14:27 , ALBERTO VIEIRA FERREIRA MONTEIRO <albmont at centroin.com.br> wrote:
Peter Dalgaard wrote:
I don't think so. I'll give you that it should either be the (number of lines - 1)*spacing or (number of linefeeds)*spacing, but it's correct to count the height of "M" only on the top line. -pd It is correct as written
Ah, ok, I see now. The "line spacing" is not the line spacing, but the inter-line spacing plus
the height of "M":
"Note that the ?height? of a string is determined only by the number of linefeeds ("\n") it contains: it is the (number of linefeeds - 1) times the line spacing plus the height of "M" in the selected font. For an expression it is the height of the bounding box as computed by plotmath. Thus in both cases it is an estimate of how far above the final baseline the typeset object extends. (It may also extend below the baseline.) The inter-line spacing is controlled by cex, par("lheight") and the ?point size? (but not the actual font in use)"
It's still confusing... Specially since there's no way to get the inter-line spacing except by running
strheight("M\nM") - 2 * strheight("M")
Alberto Monteiro
You still don't get it. It goes like this:
strheight("M\nM") - strheight("M")
[1] 0.06733925
(strheight("M\nM\nM") - strheight("M"))/2
[1] 0.06733925
(strheight("M\nM\nM\nM") - strheight("M"))/3
[1] 0.06733925
which appears to be identical to par("cxy")[2].
Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com