[R] spacing problem in main title using car package scatterplot

peter dalgaard pdalgd at gmail.com
Fri Aug 30 09:12:48 CEST 2013


On Aug 29, 2013, at 23:56 , John Fox wrote:

> Dear Gerard,
> 
> Without your data, it's not possible to reproduce your problem exactly, but
> it's clear that it isn't specific to the scatterplot() function in the car
> package. For example, try
> 
> plot(1:10)
> title(main=bquote(paste("Hypothesis 9.4.1\nBaseline XYZ with Disease
> Activity (DAS28)\nat Month 18 (N=", 100 ,")")), adj=0)

As far as I can tell, the issue is nothing to do with justification. It's because it is pasting the number onto a three-line block of text, so the longest line determines where the next thing goes. Using atop() might help, except that it doesn't left justify.  

BTW, Gerard, please don't create new threads by replying to old ones. On threading mail programs like OSX Mail, this drags in "problems with abline" from October 2010 and two other old threads...

-Peter D.

> 
> You should be able to adapt the following solution:
> 
> plot(1:10)
> mtext("Hypothesis 9.4.1\nBaseline XYZ with Disease Activity (DAS28)",
> side=3, line=2)
> mtext(paste("at Month 18 (N=", 100 ,")", sep=""), side=3, line=1)
> 
> I hope this helps,
> John
> 
> -----------------------------------------------
> John Fox
> McMaster University
> Hamilton, Ontario, Canada
> 
> 
> 
> 
>> -----Original Message-----
>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
>> project.org] On Behalf Of Gerard Smits
>> Sent: Thursday, August 29, 2013 5:00 PM
>> To: r-help at r-project.org
>> Subject: [R] spacing problem in main title using car package
>> scatterplot
>> 
>> 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)
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list
>> 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.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list