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: 1. 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) 2. 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
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@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@lists.macromates.com http://lists.macromates.com/listinfo/textmate