If you wrote it as
summary(lm(mpg ~ drat + hp, data = mtcars))
then I think it is more doable.
the command could then run with just 1 carat specifying the variable, with the content of the line allowing deduction of mtcars as the data) Return data$var to the R console is then straightforward
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
unfortunately up to now it would be a stony way to achieve this - due to TM's "alpha" status I think. The point here is that if you have more than one selection the TM variable "TM_SELECTION" holds "only" the information about the line number-start of selection:length of selection. In addition to that - even if all selections are in the SAME line - TM 2.0 doesn't set the TM variable "TM_CURRENT_LINE". This would mean if you want to get the actual content of the selections you have to calculate the contents by yourself. This could be done maybe by:
- set the tmCommand's "Input:" to "Document"
- get the entire document content
- iterate through each selection in "TM_SELECTION" by
- get line number -> get the content of the line based on the document's content
- get start and length of your selection
- get the substring (content) for each selection
- concatenate the selections by "$" to cmd
- send cmd to R.app