Howdy,
please try doing everything in expression, which is vectorized.
Like this:
print(tab.base + annotation_custom(grob=tableGrob(df,
cols=expression('Eye', "N75[ms]", N75-P100*'['*mu*'V]'))))
For bold stuff:
print(tab.base + annotation_custom(grob=tableGrob(df,
cols=expression('Eye', bold(N75*"[ms]"), N75-P100*'['*mu*'V]'))))
Hope that helps.
Cheers,
Brian
On 24.07.2015 14:05, Bryan Hanson wrote:
> Alright. gridExtra / gtable is expecting plotmath and in plotmath you
> have to escape the bracket by quoting it (found on SO). So I thought
> the following would work to escape the brackets, but it doesn’t quite:
>
> colnames(d) <- c("plain text", "text '['unit']'", “tmp text")
>
> So, again using ideas from SO, I did this, which is getting much closer:
>
> cn1 <- "plain text"
> cn2 <- expression(paste("text [unit]"))
> cn3 <- expression(paste("text [", mu*V, "]",))
> colnames(d) <- c(cn1, cn2, cn3)
>
> tt <- ttheme_default(colhead=list(fg_params = list(fontface=2, parse =
> TRUE)))
> grid.table(d, theme=tt)
>
> The remaining problem is the bolding of the expressions. There might
> be a way around this, maybe someone else will have an answer. You
> might post this partial answer to SO and see what the experts there
> have to say. There are several who are very very sharp with plotmath.
>
> There is also a new package latex2exp which I have great hopes for,
> but I couldn’t make it work in this case (but latex2exp is advertised
> as ‘beta’)
>
> Bryan
>
>> On Jul 24, 2015, at 7:13 AM, Herbert Jägle <
jae...@eye-regensburg.de
>> <mailto:
jae...@eye-regensburg.de>> wrote:
>>
>> Hi Bryan.
>> This is my intention. I want to get column labels like "name [unit]"
>> with the name of a variable and the unit in brackets. The last
>> example should give microvolt within the brackets.
>>
>> I tried to play around with the character string and did not find the
>> systematics. For example, the second label is interpreted as "text"
>> with subscript "unit", but when i add a tilde before the bracket, it
>> seems no longer interpreted.
>> Herbert
>>
>>
>> On Friday, July 24, 2015 at 12:51:00 PM UTC+2, Bryan Hanson wrote:
>>
>> Herbert, just to clarify, the only column header to be
>> interpreted in a special manner is the 3rd one, and you want it
>> to be, verbally, some text followed by square brackets enclosing
>> the symbol for microvolts? If not, what is *mu*V supposed to
>> typeset as? Bryan
>>
>>> On Jul 24, 2015, at 1:33 AM, Herbert Jägle
> <mailto:
ggplot2+u...@googlegroups.com>.