[ESS] Evaluating commented code

Kevin R. Coombes kevin.r.coombes at gmail.com
Tue Jan 22 16:54:32 CET 2013


If you switch to using either Sweave or knitR instead of straight R 
scripts, both include a natural notion of "code chunk" that is separate 
from "text chunks".  Each code chunk can be tuned off or on individually 
(by setting eval=TRUE, the default, or eval=FALSE).  Since ESS already 
knows about both of these tools, no new ess-... functions would need to 
be defined.

     Kevin

On 1/18/2013 4:56 PM, Stephen Eglen wrote:
>> When I write scripts for analyzing data, I often comment out lines of code.
>>   For example I might have something like:
>>
>> dat=read.csv()
>> plot(y~x, data) # check for outliers
>>
>> Once I've made the plot, I don't want to make it again, so I'll comment it
>> out.  And then my client sends me a revision of the data and I'll want to
>> check it again, so I uncomment the plot statement and then evaluate it, and
>> then comment the line again.
>>
>> It occurred to me today that it would be handy to have a key-combination
>> similar to ess-eval-* that removes comment characters before sending the
>> code line/block/paragraph to the inferior ess process.
>>
>> Has anyone written code to this?
> hi Kevin,
>
> I've not seen such a function.  Everything is possible though with Emacs
> of course, and a wrapper (defadvice) with M-x uncomment-region would
> help.
>
> I'm wary of the approach though, partly because it then prevents you
> including genuine text comments (not code) within your region to eval.
> You could try making your own debug function along the lines of:
>
> mydebug( plot(x,y))
>
> where mydebug is a simple function to evaluate its first argument but
> only according to some state variable.  This would then be usable if you
> ever ran your R code outside ESS (shock horror!).
>
>
> Stephen
>
> ______________________________________________
> ESS-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help



More information about the ESS-help mailing list