s-news
[Top] [All Lists]

Re: Bug in the Print command

To: Tristan Lorino <lorino@vet-alfort.fr>
Subject: Re: Bug in the Print command
From: John Fox <jfox@mcmaster.ca>
Date: Thu, 29 Aug 2002 09:25:01 -0400
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <163176206511.20020829104026@vet-alfort.fr>
Dear Tristan,

This isn't a bug, but reflects the way that print methods are supposed to work -- in addition to printing an object they return the object invisibly. When you call print at the command line, you don't see the invisible result, but the result is returned by print and will be returned by your function if it is in the last statement of the function, and then printed if not assigned.

For example:

    > fun <- function(x) print(x)
    > fun(1)
    [1] 1
    [1] 1

    > x <- print(1)
    [1] 1
    > x
    [1] 1
    >

I hope that this helps,
 John

At 10:40 AM 8/29/2002 +0200, lorino@vet-alfort.fr wrote:

Since many years, I have a problem with S-Plus (v2000 and v6, Windows NT,
2000 and Xp): when I put a "print(toto)" command
somewhere in a program, I already have "toto" printed two times!
Why?
Has anyone this problem too?

-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox@mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------


<Prev in Thread] Current Thread [Next in Thread>