R Studio macros

Hi all,

this question made me wonder: is there something similar to Excel macros in R Studio?

I mean something different from code snippets - I wouldn't be able to write a code snippet which select all code in an open file, copies it to the clipboard and then pastes it into another file, at a specific location. Maybe it's possible, combining the R Studio programmatic API with packages such as datapasta, but I was wondering if there was something simpler such as a macro recorder.

1 Like

@Andrea The main solution that comes to mind would be to create an RStudio Addin that uses the rstudioapi package (e.g. getActiveDocumentContext()). The addin could then be bound to a keyboard shortcut.

Unfortunately this requires a large amount of background knowledge (because the addin has to be saved in an R package structure), so it wouldn't be possible to record the macro.

1 Like

Thanks, John - so, it's not possible to record a macro, but it's possible to achieve the desired result programmatically if one studies the R Studio API. Good to know!

1 Like

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