Last month I asked how to select some text and press a keyboard shortcut that would send the selected text to R app: http://lists.macromates.com/textmate/2014-March/037158.html

This is working excellently well. I’m interested in extending this, but cannot figure out how to set it up.

Lets say I have this code: 

summary(lm(mpg ~ drat + hp, mtcars))

How can select 'mtcars’ and ‘hp’ simultaneously, press a keyboard shortcut and run this code in R app:

mtcars$hp

Similarly, in this code:

ddply(mtcars, .(cyl), summarise, mean(mpg))

How can select 'mtcars’ and ‘mpg’ simultaneously, press a keyboard shortcut and run this code in R app:

mtcars$mpg

Thanks
Ross