Rstudio addins to examine selected code in the Rstudio editor.
Berry Boessenkool ([email protected]), May 2017, with
selectobject code idea from
I find it very useful to bind the addins to keyboard shortcuts like this (and label the keyboard):
hist(selected_code, col="moccasin", breaks=50, las=1)
To use such keyboard shortcuts, follow these instructions:
if(!requireNamespace("remotes")) install.packages("remotes") remotes::install_github("brry/rskey") # either set all bindings: rskey::setKeyboardBindings(overwrite=TRUE) # by default also sets CTRL+Y for ReDo and CTRL+H for setWorkingDirToActiveDoc # or manually: # Rstudio - Tools - Modify Keyboard Shortcurts # click on an addin shortcut field and press the desired key combination # (Restart Rstudio)
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
This works even if the package is not installed (in which case you do need the quotation marks).
In the default browser, it the opens the first link if it exists, the second if not:
The 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.
funSource-initiated github search doesn't find
dimnames in base R.
Any idea to solve this kind of limitation is welcome!
funSource is imported from
Examples on links opened by
Functions in CRAN packages -
https://github.com/search?q=rescale function repo:cran/spatstat+path:R
Functions in base packages -
https://github.com/search?q=hist function repo:wch/r-source+path:src/library/graphics/R
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.