Re: [Rd] substitute creates an object which prints incorrectly (PR#9427)

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Fri 22 Dec 2006 - 12:17:02 GMT

Try issuing the command:

   options(keep.source = FALSE)

prior to running the code you displayed to force the actual source, rather than the source attribute, to be displayed by print when printing functions.

On 12/21/06, Bill.Venables@csiro.au <Bill.Venables@csiro.au> wrote:
> The function "substitute" seems to fail to make a genuine
> substitution, although the printed verision seems fine. Here is an
> example.
>

> > m <- substitute(Y <- function(x) FUN(x+1),

> + list(Y = as.name("y"), FUN = as.name("sin")))
> > m
> y <- function(x) sin(x + 1)
> > eval(m)
> > y
> function(x) FUN(x+1)
>
> However the story doesn't end there. The substitution appears to have
> been made, even though the printed version, this time, suggests
> otherwise.
>
> > y(pi)
> [1] -0.841471
> > sin(pi+1)
> [1] -0.841471
> >
>
> Bill Venables
> CMIS, CSIRO Laboratories,
> PO Box 120, Cleveland, Qld. 4163
> AUSTRALIA
> Office Phone (email preferred): +61 7 3826 7251
> Fax (if absolutely necessary): +61 7 3826 7304
> Mobile (rarely used): +61 4 1963 4642
> Home Phone: +61 7 3286 7700
> mailto:Bill.Venables@csiro.au
>
http://www.cmis.csiro.au/bill.venables/
>
>
> --please do not edit the information below--
>
> Version:
> platform = i386-pc-mingw32
> arch = i386
> os = mingw32
> system = i386, mingw32
> status =
> major = 2
> minor = 4.1
> year = 2006
> month = 12
> day = 18
> svn rev = 40228
> language = R
> version.string = R version 2.4.1 (2006-12-18)
>
> Windows XP Professional (build 2600) Service Pack 2.0
>
> Locale:
> LC_COLLATE=English_Australia.1252;LC_CTYPE=English_Australia.1252;LC_MON
> ETARY=English_Australia.1252;LC_NUMERIC=C;LC_TIME=English_Australia.1252
>
> Search Path:
> .GlobalEnv, .R_Store, package:RODBC, package:xlsReadWrite,
> package:cluster, package:vegan, package:ASOR, package:stats,
> package:graphics, package:grDevices, package:utils, package:datasets,
> .R_Data, .R_Utils, package:svIDE, package:tcltk, package:methods,
> Autoloads, package:base
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Dec 22 23:22:08 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 22 Dec 2006 - 16:31:03 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.