Posts

Showing posts with the label add-in

Build a RStudio addin to debug pipe chains

Build a RStudio addin to debug pipe chains I wrote a function that helps executing pipe chains step by step. To use it the users has to copy the instruction to clipboard, then execute the function, and move to the console to proceed. I would like to build an addin that would allow me to select the instructions and run the function with Ctrl + P without the awkward steps. Ctrl + P Ideally, the addin would : I believe it's extremely similar to what the reprex addin is doing but I don't know where to start as I'm 100% new to addins. I looked into rstudioapi::getActiveDocumentContext() but there was nothing there of interest to me. rstudioapi::getActiveDocumentContext() How can I make this work ? The function debug_pipe <- function(.expr){ .pchain <- if (missing(.expr)) readClipboard() # windows only , else try clipr::read_clip() else deparse(substitute(.expr)) .lhs <- if (grepl("^\s*[[:alnum:]_.]*\s*<-",.pchain[1])) { sub("^\s*([[:...