Run a single line as local Job

Hello,

I was wondering, if it is possible, to run a single line of R code as a local job instead of a whole script. I think this would be incredibly useful, because I often only have a single line which takes a lot of time, and this would allow me to do other stuff in the same script, while the one function is computed in the background.

Ideally, there would be a shortcut (i.e. shift+enter) to run a line as a job instead of the normal way (ctrl+enter)

big_result  <-  function_which_takes_very_long(...)
# while this gets executed explore some other results
plot(c(1,2),c(3,4))

Thanks for any help!

Cheers!

Hello nickhir,

you can indeed run only selected lines as a Background job. Just select them with your mouse and press the button "Source as Background job". If all objects you want to use are in your current global environment, you can access them via ticking "Run job with copy of global environment".

Unfortunetaly, there is at least to my knowledge no short cut to run a process as Background job. I guess this is due to the fact, that the menu which opens with the button "Source as Background job" has some options to modify (like the script to run - but within the same script selection works too).

Maybe an RStudio / Posit developer does know something about an existing short cut or upcoming updates which introduce this.

Kind regards

Brilliant, thank you!

Just for the record, for me I had to press Run Selection as Local Job under the Code tab. :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.