<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;"><div>Hi all</div><div><br></div><div>I have some .Rnw files with in-line R code, like this:</div><div><br></div><div>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)}.</div><div><br></div><div>I’m wondering if its possible to do two things:</div><ol><li>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)</li><li>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)}</li></ol><div>Thanks</div><div>Ross</div><div><br></div></body></html>