From jarioksa at sun3.oulu.fi  Wed May  9 10:10:22 2007
From: jarioksa at sun3.oulu.fi (Jari Oksanen)
Date: Wed, 09 May 2007 08:10:22 +0000
Subject: [Rd] step() in sink() and Sweave()
Message-ID: <1178698222.28498.18.camel@biol102145.oulu.fi>

Dear developers,

I just noticed that step() function currently prints the current model
using message(), but the resulting model using print(). The relevant
commands within the step() body are:

if (trace) message("Start:  AIC=", format(round(bAIC, 2)), "\n", 
    cut.string(deparse(as.vector(formula(fit)))), "\n")

(with example() output:) 
Start:  AIC=190.69
Fertility ~ Agriculture + Examination + Education + Catholic + 
    Infant.Mortality

And later:

if (trace) print(aod[o, ])

(with example() output:)

                   Df Sum of Sq    RSS    AIC
- Examination       1      53.0 2158.1  189.9
<none>                          2105.0  190.7
- Agriculture       1     307.7 2412.8  195.1
- Infant.Mortality  1     408.8 2513.8  197.0
- Catholic          1     447.7 2552.8  197.8
- Education         1    1162.6 3267.6  209.4

This is a nuisance if you want to divert output to a file with sink() or
use step() in Sweave: the header and the table go to different places,
and without message() part the print() part is crippled.  It may be that
there is some way to avoid this, but obviously that needs some degree of
acrobatic R skills. 

An example of the behaviour:

sink(tempfile())
example(step)
sink()

I assueme that the behaviour is intentional but searching NEWS did not
give any information or reasoning. Would it be sensible to go back to
the old behaviour? I found some Swoven files from R 2.4.0 that still put
both parts of the output to the same place. For the sake of Sweave and
sink, I'd prefer the one place to be stdout instead of stderr.

Best wishes, Jari Oksanen
-- 
Jari Oksanen <jarioksa at cc.oulu.fi>



[Rd] step() in sink() and Sweave()
Jari Oksanen