Learn R Programming

rstudioapi (version 0.14)

rstudio-editors: Retrieve Information about an RStudio Editor

Description

Returns information about an RStudio editor.

Usage

getActiveDocumentContext()

getSourceEditorContext(id = NULL)

getConsoleEditorContext()

Value

A list with elements:

idThe document ID.
pathThe path to the document on disk.
contentsThe contents of the document.
selectionA list of selections. See Details for more information.

Arguments

id

The ID of a particular document, as retrieved by documentId() or similar. Supported in RStudio 2022.06.0 or newer.

Details

The selection field returned is a list of document selection objects. A document selection is just a pairing of a document range, and the text within that range.