[TxMt] Re: Working with in-line R code

Tim Bates timothy.c.bates at gmail.com
Sat Mar 22 14:06:29 UTC 2014


I’d add a scope to the outer document (markdown?) which grabs   (\Sexpr{)(.*)(}) and injects R into the middle capture.
then you inherit the ability to execute the R inside with Hans Jorg Bibiko’s applescript command for executing code

On 22 Mar 2014, at 08:48, Ross Ahmed <rossahmed at googlemail.com> wrote:

> Hi all
> 
> I have some .Rnw files with in-line R code, like this:
> 
> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua \Sexpr{mean(mtcars$hp)}. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat \Sexpr{mean(mtcars$mpg)}. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum \Sexpr{mean(mtcars$wt)}.
> 
> I’m wondering if its possible to do two things:
> Place cursor inside a Sweave expression then run the code contained within that expression to R app. So if I place the cursor anywhere between \ and } in any of the three Sweave expressions above, the code within that expression would be run in R app. For example, if I place the cursor between “h” and “p”, then this would be ran in R app: mean(mtcars$hp)
> Select any text and run any R code within the selected text to R app. So if if select the entire text above, three lines of code would be run in R app: \Sexpr{mean(mtcars$hp)}, \Sexpr{mean(mtcars$mpg)} and \Sexpr{mean(mtcars$wt)}
> Thanks
> Ross
> 
> 
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20140322/f1047e62/attachment.html>


More information about the textmate mailing list