if (FALSE) {
# Need to run in RStudio
# Please read the Section 'Details' carefully
# --------------------------------------------
# I assume the shortcuts are Alt+1,2,...,9,0,
# corresponding to shortcuts 1 - 10
# Adds an insertion to Alt+9
rs_add_insertion_shortcut(9, " %?<-% ", force = TRUE)
# restart RStudio and try `Alt+9`
# Adds an expression to Alt+2
rs_add_shortcut(2, {
expr <- sprintf("system.time({\n%s\n})\n",
rstudioapi::selectionGet()$value)
cat(expr)
eval(parse(text = expr))
}, force = TRUE)
# Select any valid R code and press Alt+1
# --------------------------------------------
# run this to set your shortcut (one-time setup)
rs_add_shortcut(1, { dipsaus::rs_quick_debug() })
# Add debug feature: insert the following comment anywhere in your code
# You may open a new script in the RStudio
# DIPSAUS: DEBUG START
# message("Debugging...")
# a <- 1
# print(a)
# message("Finished")
# Place your cursor here, press the shortcut key
}
Run the code above in your browser using DataLab