[R] problem with newline using bquote(paste())
Gerard Smits
g_smits at verizon.net
Fri Aug 30 19:47:31 CEST 2013
That explains it. Thanks for the info. Gerard
On Aug 30, 2013, at 8:42 AM, Marc Schwartz <marc_schwartz at me.com> wrote:
>
> On Aug 30, 2013, at 10:26 AM, Gerard Smits <g_smits at verizon.net> wrote:
>
>> Hi All,
>>
>> This is a variant of a problem I posted yesterday (see below) where I found I had a large gap between my N= and he number I had evaluated using .(x). I seem to have trouble with newlines in a main title. I find now that all works as expected (no unsightly gap between my N= and the value, if all of the title is put on the same line. Whenever I try the newline, I run into problems.
>>
>> Below, I have one example that gives me no syntax errors, but simply does not print the information after the \n (the N= xxx) part.
>>
>> Any help appreciated.
>>
>> Thanks,
>>
>> Gerard
>>
>> PS using R 3.0.0
>>
>>
>> ss<-n(m18_das28*b_dascore)
>> par(oma=c(2,2,2,2))
>> scatterplot(m18_das28~b_score,
>> jitter=list(x=1, y=1),
>> grid=F,
>> smooth=F,
>> las=1,
>> pch=c(1),
>> col='blue',
>> main=as.expression(bquote(paste("Baseline xyz with Month 18 DAS28\n")), bquote(paste("(N=",.(ss),")"))),
>> xlab="Baseline xyz",
>> ylab="Month 18 DAS28",
>> legend.plot=F)
>>
>>
>>
>>
>> Prior, related post:
>>
>> On Aug 29, 2013, at 2:00 PM, Gerard Smits <g_smits at verizon.net> wrote:
>>
>>> Hi All,
>>>
>>> I'm using R 3.0.0. I'm trying to add the sample size of the paired data (calculated by a function n(), which returns a value of 70, correctly).
>>>
>>> My main title works fine except that the '70' appears far to the right on the line as in:
>>>
>>> at Month 18 (N= 70)
>>>
>>> Is there a way of left justifying the result of .(ss)? or some other way of removing with whitespace between n= and 70?.
>>>
>>> Thanks for any suggestions.
>>>
>>> Gerard
>>>
>>>
>>>
>>>
>>> library (car)
>>> data<-read.csv("//users//smits//r_work//data.csv", header = TRUE)
>>> attach(data);
>>>
>>> ##################################################################################################################
>>> ss<-n(m18_das28*b_score)
>>>
>>> scatterplot(m18_das28~b_score,
>>> jitter=list(x=1, y=1),
>>> grid=F,
>>> smooth=F,
>>> las=1,
>>> pch=c(1),
>>> col='blue',
>>> main=bquote(paste("Hypothesis 9.4.1\nBaseline XYZ with Disease Activity (DAS28)\nat Month 18 (N=",.(ss),")")),
>>> xlab="Baseline XYZ",
>>> ylab="Month 18 DAS28",
>>> legend.plot=F)
>>>
>
>
>
> You cannot use newlines in plotmath expressions. You will need to create each line of the plot title text separately using ?mtext instead of specifying 'main' in the plot call.
>
> Regards,
>
> Marc Schwartz
>
More information about the R-help
mailing list