From ggrothendieck at gmail.com  Tue Sep 22 14:23:00 2009
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Tue, 22 Sep 2009 08:23:00 -0400
Subject: [Rd] A couple of suggestions: source function (package base)
In-Reply-To: <c86bda880909211822x28dbdecfqecdf7af7adfc3767@mail.gmail.com>
References: <c86bda880909211822x28dbdecfqecdf7af7adfc3767@mail.gmail.com>
Message-ID: <971536df0909220523l5b90e1b8wa26e2759c32e76dd@mail.gmail.com>

I would find that useful too particularly for running long output from Stangle.

On Mon, Sep 21, 2009 at 9:22 PM, Jose Claudio Faria
<joseclaudio.faria at gmail.com> wrote:
> Hi,
>
> I've been calling the function "source" (package base) from Tinn-R editor to
> send files, marked blocks and selections to R interpreter because it avoids a
> lot of problems related with input/output synchronization in the Rgui output!
>
> The new RGedit plugin is also using this function in this way, and we are
> finishing a new version of a plugin to Vim (Vim-R-plugin2) which uses
> also source().
>
> So, I would like to propose two small changes in this function:
>
> 1. The "max.deparse" parameter could be a global option with 150 as
> the default value.
>
> ? Why? It will avoid the need to send this parameter repeatedly,
> which causes visual pollution in the console.
>
> 2. A new parameter (for example: "new.line") to allow the user to
> define whether a new blank line between the output and the subsequent
> input is desired when "echo=T".
>
> Example, suppose I have in the editor the three lines below:
>
> a=rnorm(10)
> a
> sort(a)
>
> and I would like to send it to R interpreter (file, block or selection).
>
> The current output is (using Vim-R-plugin2):
> -------------------------------------------
>> source('/tmp/.Rsource-jcfaria', echo=TRUE, max.deparse=50)
>
>> a=rnorm(10)
>
>> a
> ?[1] ?0.08648104 -1.74996635 ?0.61027538 ?0.42042031 -0.02025884 -0.39891256
> ?[7] -0.30219635 -0.84476668 ?1.06341674 -0.12030620
>
>> sort(a)
> ?[1] -1.74996635 -0.84476668 -0.39891256 -0.30219635 -0.12030620 -0.02025884
> ?[7] ?0.08648104 ?0.42042031 ?0.61027538 ?1.06341674
>
>>
>
>
> How it could be (desired):
> -------------------------
>> source('/tmp/.Rsource-jcfaria', echo=TRUE)
>> a=rnorm(10)
>> a
> ?[1] ?0.08648104 -1.74996635 ?0.61027538 ?0.42042031 -0.02025884 -0.39891256
> ?[7] -0.30219635 -0.84476668 ?1.06341674 -0.12030620
>> sort(a)
> ?[1] -1.74996635 -0.84476668 -0.39891256 -0.30219635 -0.12030620 -0.02025884
> ?[7] ?0.08648104 ?0.42042031 ?0.61027538 ?1.06341674
>>
>
> I think that both "new.line" and "max.deparse" could be both global options.
>
> max.deparse = 150 (default)
> new.line ? ?= FALSE (default)
>
> Why? To get a clearer output.
>
> In this way the args of this function would become:
> ---------------------------------------------------
> function (file, local = FALSE, echo = verbose, print.eval = echo,
> ? ?verbose = getOption("verbose"), prompt.echo = getOption("prompt"),
> -> ?max.deparse.length = getOption("max.deparse"), new.line =
> getOption("new.line"), <-
> ? ?chdir = FALSE, encoding = getOption("encoding"), continue.echo =
> getOption("continue"),
> ? ?skip.echo = 0, keep.source = getOption("keep.source"))
>
> For GUI/Editor developers this changes will allow to send simpler
> instructions and
> make nice and standard interfaces.
>
> Is it possible to create the "new.line" argument and to put it and
> "max.deparse" between the global options?
>
> I would prefer not creating a custom version of source() because I
> think that these changes would be of
> benefit to other people and projects.
>
> Thanks,
> --
> ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
> Jose Claudio Faria
> Estatistica - prof. Titular
> UESC/DCET/Brasil
> joseclaudio.faria at gmail.com
> joseclaudio.faria at terra.com.br
> ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] A couple of suggestions: source function (package base)
Gabor Grothendieck