[R] Is this a bug?

Prof Brian D Ripley ripley at stats.ox.ac.uk
Thu Jul 13 08:45:31 CEST 2000


On Thu, 13 Jul 2000, Pedro J. Aphalo wrote:

> I am new to R (and S) and I hope someone on the list can help me out. I
> find the following behaviour surprising, is it a bug or a feature?
> (looks like a bug to me)

No, it is a feature.  summary does not print anything. If you want results
from within a function you need to explicitly print them. However, a
function returns the result of evaluating the last expression, and objects
at the session level (only) are automatically printed.

> R Version 1.1.0, Windows (x86, Win32) June 15, 2000
> OS Windows 95
> 
> cat.test <- function(){
>     summary(c(1:20))
>         
>     cat("test\n")
>     }
> 
> summary produces no output, just "test" appears on RGUI's window. 

(c(1:20) is the same as 1:20.)

> If the line cat("test\n") is commented out, summary produces its normal
> output.
> 
> Same lack of  summary output on Rterm, but command prompt does not
> reappear and Rterm freezes.
> With the line cat("test\n") commented out everything works fine.
> 
> The behaviour for RGUI is the same whether the function is sourced from
> a file or defined at the command prompt. With Rterm I have not yet found
> how to type in brackets with a Finnish keyboard, so the test was done by
> sourcing a file.

Well, that's not the same thing. Typing your example at interactive rterm
session certainly works here.  If you have a reproducible example that
freezes Rterm, please send in a bug report, and we will try to reproduce
it (and if we can reproduce it, try to fix it).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list