Package 'rskey'

Title: Create Custom 'Rstudio' Keyboard Shortcuts
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'.
Authors: Berry Boessenkool [aut, cre]
Maintainer: Berry Boessenkool <[email protected]>
License: GPL(>= 2)
Version: 0.4.15
Built: 2025-01-07 04:59:33 UTC
Source: https://github.com/brry/rskey

Help Index


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, [email protected], 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, [email protected], Apr 2019

See Also

selectobject


pass Rnw document to knit2pdf

Description

pass the filename (selected window) to knitPres::rnw2pdf. Developed when MikTex and Rstudio stopped talking to each other. Can be schorcut to e.g. CTRL + K

Usage

bknit2pdf(open = TRUE, clean = TRUE, ...)

Arguments

open

Open pdf file?

clean

Clean up temporary files? DEFAULT: TRUE (unlike in tools::texi2pdf)

...

Further arguments passed to knitr::knit

Value

invisible charstring with file name

Author(s)

Berry Boessenkool, [email protected], Jul 2021


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, [email protected], Oct 2021

See Also

selectobject, rcode


run python exercise development test

Description

run python exercise development test

Usage

pycheck()

Author(s)

Berry Boessenkool, [email protected], Jan 2023

See Also

selectobject


wrap Rnw source code in "\rcode"

Description

wrap Rnw source code in "\rcode"

Usage

rcode()

Author(s)

Berry Boessenkool, [email protected], 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, [email protected], 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, [email protected], 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, [email protected], Feb 2022

See Also

[berryFunctions::convertUmlaut]