inst/doc/visual-mode.R

## ---- include = FALSE---------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(rstudioapi)

## ----eval=FALSE---------------------------------------------------------------
#  reformat <- function() {
#    id <- rstudioapi::documentId(allowConsole = TRUE)
#    selection <- rstudioapi::selectionGet(id = id)
#    formatted <- styler::style_text(text = selection$value)
#    rstudioapi::selectionSet(value = formatted, id = id)
#  }

Try the rstudioapi package in your browser

Any scripts or data that you put into this service are public.

rstudioapi documentation built on July 9, 2023, 6:59 p.m.