Rstudio addins to examine selected code in the Rstudio editor.
Berry Boessenkool (berry-b@gmx.de), 2017-2026
install.packages("remotes")
# remotes::install_github("brry/rskey")
install.packages("rskey", repos = c('https://brry.r-universe.dev', 'https://cloud.r-project.org'))
rskey::setKeyboardBindings()
# moves existing shortcuts to backup file
F3: structure of an object - str(selected_code)
F4: head of an object - head(selected_code)
F5: tail of an object - tail(selected_code)
F6: View an object - View(selected_code)
F7: funSource of an object - funSource(selected_code)
F8: summary of an object - summary(selected_code)
F9: dim of an object - dim(selected_code)
F10: class of an object - class(selected_code)
F11: plot an object - plot(selected_code, las=1)
F12: histogram of an object - hist(selected_code, col="moccasin", breaks=50, las=1)
CTRL/CMD + Y: redo (by removing it from paste last yank)CTRL + H: set working dir to active documentALT + S: quarto render documentALT+W, or control+W: toggle line wrapping (depending on OS)CTRL/CMD + Shift + Y: score for course
CTRL/CMD + R: add \rcode{text} around text in an Rnw documentCTRL/CMD + K: knit Rnw file to pdf rskey::bknit2pdf (set to knitDocument if wanted)CTRL/CMD + Shift + D: roxygenizePackage to enable duplicate text/line inside a packageCTRL/CMD + Shift + K: knitDocument as I prefer CTRL/CMD + K
selectively (un)set some manually:
label the keyboard if wanted :)
funSource provides an easy option to open the source code of a function in a browser window.
Through github, there are nice syntax highlighting and search options.
funSource(someFunction) tries to find the corresponding package to the input function.
You can also explicitly request funSource("somePackage::someFunction").
This works even if the package is not installed (in which case you do need the quotation marks).
In the default browser, it opens the first link if it exists, the second if not:
somePackage/blob/master/R/someFunction.R (or .r file)someFunction function repo:cran/somePackage+path:RThe second link is a github search query needed when a function is defined in a file with a different name.
Functions in the base R packages will be searched in the
wch/r-source/src/library repo.
Currently, the funSource-initiated github search doesn't find names or dimnames in base R.
Any idea to solve this kind of limitation is welcome!
funSource is imported from
berryFunctions.
The selectobject code idea is from digital-dharma/RStudioAddIns).
Examples on links opened by funSource:
Functions in CRAN packages - ggplot2::aes:
https://github.com/cran/ggplot2/blob/master/R/aes.R
https://github.com/search?q=aes function repo:cran/ggplot2+path:R
Functions in base packages - graphics::hist:
https://github.com/wch/r-source/blob/trunk/src/library/graphics/R/hist.R
https://github.com/search?q=hist function repo:wch/r-source+path:src/library/graphics/R