Title: Create Custom 'Rstudio' Keyboard Shortcuts
Version: 0.4.19
Date: 2025-04-01
Description: Create custom keyboard shortcuts to examine code selected in the 'Rstudio' editor. F3 can for example yield 'str(selection)' and F7 open the source code of CRAN and base package functions on 'github'.
Imports: graphics, utils, rstudioapi (≥ 0.5), berryFunctions (≥ 1.17.21)
Suggests: knitr, pillar
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Encoding: UTF-8
RoxygenNote: 7.3.2
BugReports: https://github.com/brry/rskey/issues
NeedsCompilation: no
Packaged: 2025-04-01 18:05:58 UTC; Berry
Author: Berry Boessenkool [aut, cre]
Maintainer: Berry Boessenkool <berry-b@gmx.de>
Repository: CRAN
Date/Publication: 2025-04-01 18:20:02 UTC

Rstudio keyboard shortcuts on F-keys

Description

Rstudio addins to examine highlighted code / object. It can be very useful to bind these addins as outlined in https://github.com/brry/rskey#rstudio-addins-for-keyboard-shortcuts

Usage

str_addin(
  obj = selectobject(),
  use_glimpse = getOption("rskey_glimpse", FALSE)
)

head_addin(obj = selectobject())

tail_addin(obj = selectobject())

View_addin(obj = selectobject())

funSource_addin(obj = selectobject(eval = FALSE))

summary_addin(obj = selectobject())

dim_addin(obj = selectobject())

class_addin(obj = selectobject())

plot_addin(obj = selectobject())

hist_addin(obj = selectobject())

unique_addin(obj = selectobject())

Arguments

obj

List containing object (some R object) fullcode (code, objectname, expression) and code (potentially truncated version). For funSource_addin, only the function name should be highlighted. DEFAULT: Rstudio addin selected code from selectobject

use_glimpse

Logical: use pillar::glimpse instead of base::str? Can be set to TRUE with options(rskey_glimpse=TRUE). To set permananently, use: cat("options(rskey_glimpse=TRUE)\n", file="~/.Rprofile", append=TRUE). DEFAULT: getOption("rskey_glimpse", FALSE)

Value

Output of the respective functions

Author(s)

Berry Boessenkool, berry-b@gmx.de, May 2017

See Also

selectobject, berryFunctions::funSource, https://github.com/daattali/addinslist#readme

Examples

# Go to Addins - browse Addins - Keyboard shortcuts - map commands as desired
# or use    setKeyboardBindings()

# highlight objects or code (examples below), then press keyboard shortcut
iris
iris$Sepal.Length + 10


Create documentation for a function

Description

Create Roxygen documentation skeleton for a function

Usage

bdoc()

Value

invisible charstring, but mainly used for writing into the source file directly

Author(s)

Berry Boessenkool, berry-b@gmx.de, Apr 2019

See Also

selectobject


wrap URL in Rnw source code in "href link text"

Description

wrap URL in Rnw source code in "href link text"

Usage

href()

Author(s)

Berry Boessenkool, berry-b@gmx.de, Oct 2021

See Also

selectobject, rcode


wrap Rnw source code in "\rcode"

Description

wrap Rnw source code in "\rcode"

Usage

rcode()

Author(s)

Berry Boessenkool, berry-b@gmx.de, Nov 2019

See Also

selectobject


Select object

Description

Rstudio addin to create object from highlighted object name or code. Also works in browser mode, albeit not in the code_browser window.

Usage

selectobject(eval = TRUE)

Arguments

eval

Should text be evaluated? If FALSE, the output is a charstring of the marked text. DEFAULT: TRUE

Value

List with the (evaluated) object and the code generating it as a character string

Author(s)

Berry Boessenkool, berry-b@gmx.de, May 2017

References

Heavily borrowed from digital-dharma/RStudioAddIns (no longer online)

See Also

addins, funSource

Examples

# see str_addin


Set Rstudio keyboard bindings

Description

Set Rstudio keyboard bindings as mapped on https://github.com/brry/rskey#rskey. By default, this overwrites existing F3:F12 mappings!

Usage

setKeyboardBindings(
  overwrite = TRUE,
  removeLastYank = TRUE,
  workdir2filedir = TRUE,
  roampath = paste0(Sys.getenv("APPDATA"), "/RStudio/keybindings"),
  openfolder = TRUE
)

Arguments

overwrite

Logical. Should existing mappings on F3, F4, ..., F12 be overwritten? Still informs if this occurs. DEFAULT: TRUE

removeLastYank

Logical. Should the annoying Rstudio default to override "Redo" (CTRL+Y) with some weird yank be removed? DEFAULT: TRUE (CTRL+Y becomes "Redo" again)

workdir2filedir

Logical. Set CTRL+H for setWorkingDirToActiveDoc? DEFAULT: TRUE

roampath

Char. If not NULL, both files are also copied to this path, e.g. C:/Users/berry/AppData/Roaming/RStudio/keybindings. Seems to be irrelevant in Rstudio 1.4. DEFAULT: RStudio/keybindings folder at Sys.getenv("APPDATA")

openfolder

Logical: Open folder(s) after writing the files? Uses berryFunctionsopenFile(). DEFAULT: TRUE

Value

Returns nothing

Author(s)

Berry Boessenkool, berry-b@gmx.de, Jan 2019

See Also

addins


Umlaut to ASCII

Description

Convert Umlaute in Script to ASCII. Less aggressive than <https://github.com/dreamRs/prefixer/#not-ascii>

Usage

umlaut2ascii()

Value

path, invisibly

Author(s)

Berry Boessenkool, berry-b@gmx.de, Feb 2022

See Also

berryFunctionsconvertUmlaut()