There is a difference between parsed functions and .R files.  What you see when 
you type the name of a function alone on the R command line is a text 
representation of the parsed function that is ready to run in RAM. That has 
none of the comments or whitespace from the function as you wrote it.  The 
parsed version is what the "edit" function allows you to modify. This is why we 
use .R files.

FWIW I never use the "edit" function. I use a separate window for editing the 
code I want to keep, and either copy/paste the bits I want to execute (with or 
without the use of macros to facilitate that) into the R command line, or use 
the "source" function to pull in a set of functions all at once.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnew...@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Jeff Freedman <jfreed...@awstruepower.com> wrote:

>Since installing R 2.14.0 on my Mac (a Mac Pro running 10.6.8) an issue
>has arisen when using the vi editor in conjunction with the edit()
>command. More specifically, commented lines disappear from edited
>functions when using [functionname.R] <- edit().
>
>That is, if you have created a function called �test.func� as such:
>
>function ()
>{
># This is a test
>ex _ 4
>    duh <- seq(1, 10)
>    fuh <- seq(11, 20)
>    plot(duh, fuh)
>}
>
>you will of course get an error message:
>
>Error in edit(name, file, title, editor) :
>  unexpected input occurred on line 4
> use a command like
> x <- edit()
> to recover
>
>When using the �x <- edit� (or in this case, test.func <- edit()), the
>comment �This is a test� will disappear from the edited function.
>
>Does anyone have any insight into this problem?
>
>Thanks,
>Jeff Freedman
>
>_____________________________
>Jeff Freedman
>Lead Research Scientist
>AWS Truepower, LLC
>463 New Karner Road
>Albany, NY 12205
>phone: 518-213-0044 (x1049)
>fax: 518-640-6897
>
>
>       [[alternative HTML version deleted]]
>
>______________________________________________
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to