Package 'spAddins'

Title: RStudio Add-ins to Format R Markdown files (RETIRED PACKAGE)
Description: The development of `spAddins` ended in 2018 as the package retired in favor of packages `addins.rmd` and `addins.rs`. ... RStudio Add-ins to Format Text and Insert Operators ... A set of RStudio addins that are designed to be used in combination with user-defined RStudio keyboard shortcuts. These addins either: 1) insert text at a cursor position (e.g. insert operators %>%, <<-, %$%, etc.), 2) replace symbols in selected pieces of text (e.g., convert backslashes to forward slashes which results in stings like "c:\data\" converted into "c:/data/") or 3) enclose text with special symbols (e.g., converts "bold" into "**bold**") which is convenient for editing R Markdown files.
Authors: Vilmantas Gegzna [aut, cre, cph]
Maintainer: Vilmantas Gegzna <[email protected]>
License: MIT + file LICENSE
Version: 0.2.3
Built: 2024-11-02 03:11:45 UTC
Source: https://github.com/gegznav/spaddins

Help Index


Add-ins for basic R Markdown formatting.

Description

RStudio add-ins, which enclose selected text with symbols that have special interpretation in R Markdown. Function, symbols and interpretation

  • rmd_bold(): between ** and ** as bold;

  • rmd_italics(): between _ and _ as italics;

  • rmd_bold_italics(): between **_ and _**as bold italics;

  • rmd_bold2(): between __ and __ as bold;

  • rmd_italics2(): between * and * as italics;

  • rmd_code_inline(): between back-ticks (“) as inline code;

  • rmd_r_code_inline(): formats text as inline R code to evaluate;

  • rmd_superscript(): between ^ and ^ as superscript;

  • rmd_subscript(): between ~ and ~ as subscript;

  • rmd_strikethrough(): between ~~ and ~~ as strike-through text.

Usage

rmd_a_bold()

rmd_a_italics()

rmd_a_bold_italics()

rmd_a_bold2()

rmd_a_italics2()

rmd_code_inline()

rmd_code_inline_r()

rmd_code_inline_highlighted_as_r()

rmd_a_superscript()

rmd_a_subscript()

rmd_a_strikethrough()

rmd_horizontal_rule()

rmd_link_url()

rmd_insert_figure()

See Also

Other R Markdown formatting add-ins: rmd_code_block, rmd_equations, rmd_list


Insert HTML elements.

Description

RStudio add-in to insert HTML elements

RStudio add-in to insert either ->, ->>, <- or <<- at the cursor position.

Usage

html_insert_space()

rs_insert_arrow_rl()

rs_insert_arrow_rl2()

rs_insert_arrow_lr()

rs_insert_arrow_lr2()

Note

use hotkeys combination ALT + - to insert <- in RStudio.

See Also

Assignment operators assignOps.

Other 'Insert at cursor position' addins: insert_symbol_sequences

Other 'Insert at cursor position' addins: insert_symbol_sequences

Examples

## Not run: 
\donttest{
library(spAddins)

rs_insert_arrow_rl()
## <-

rs_insert_arrow_rl2()
## <<-

rs_insert_arrow_lr()
## ->

rs_insert_arrow_lr2()
## ->>
}

## End(Not run)

Insert magrittr operators.

Description

These add-ins insert operators %>%, %<>%, %$%, and %T>% at the cursor position. The operators are defined in package magrittr.

Usage

rs_insert_pipe()

rs_insert_update_pipe()

rs_insert_exposition_pipe()

rs_insert_tee_pipe()

Note

Operator does not work unless package magrittr or equivalent is loaded.

See Also

  • Forward pipeline operator %>%

  • Compound assignment pipe operator %<>%

  • Exposition pipe operator %$% and operator $

  • Tee operator %T>%

Other 'Insert at cursor position' add-ins: rs_insert_infix_R, rs_insert_infix_in, rs_insert_infix_not_in, rs_insert_matrix_multiplication


Insert various lines.

Description

Use rs_insert_ss_line() to insert ------;
rs_insert_ds_line() to insert ======;
rs_insert_dw_line() to insert ~~~~~~ at the cursor position.

Usage

rs_insert_line_ss(start = rs_get_ind_first_selected_col(), end = 79)

rs_insert_line_ds(start = rs_get_ind_first_selected_col(), end = 79)

rs_insert_line_sw(start = rs_get_ind_first_selected_col(), end = 79)

Arguments

start

(numeric) The number of column the line begins at.

end

(numeric) The number of column the line ends at.

See Also

Other 'Insert at cursor position' addins: insert_arrows


Repeat sequence of symbols.

Description

Repeat sequence of symbols.

Usage

repeat_symbol(text, length.out)

Arguments

text

(character) The symbol (or sequence of symbols) to be repeated until desired length of string.

length.out

(integer) The length of the sequence.

Value

Sting of defined length.

Examples

repeat_symbol(".", 10)

repeat_symbol("..+", 10)

Replace slash.

Description

RStudio add-in to manage various types of slashes. Select a piece of text with a cursor and do the necessary replacement operation in the selected text:

  • rs_replace_slash_bs2d single back-slash into double back-slash;

  • rs_replace_slash_bd2s double back-slash into single back-slash;

  • rs_replace_slash_b2fw back-slash into forward-slash;

  • rs_replace_slash_fw2b forward-slash into back-slash.

Usage

rs_replace_slash_bs2d()

rs_replace_slash_bd2s()

rs_replace_slash_b2fw()

rs_replace_slash_fw2b()

Convert rows into the block of code.

Description

RStudio add-in to insert selected lines into code block:

  • rmd_code_block() - verbatim code block;

  • rmd_code_block_r() - R code block.

. rmd_code_block_r_split() - splits block of R code.

These functions internally use function rs_enclose_all_with_lines() - that adds lines above and below the selection.

Usage

rmd_code_block_r()

rmd_code_block()

rmd_code_block_r_split()

See Also

Other R Markdown formatting add-ins: format_rmd, rmd_equations, rmd_list


Format as LaTeX equation.

Description

Select a piece of text with a cursor and call these functions as an add-in to enclose the text with special symbols. Text between $.$ is interpreted as an inline equation and between $$.$$ or \[.\] as a block equation in R Markdown.

Usage

rmd_equation_inline()

rmd_equation_block()

rmd_equation_block2()

See Also

Other R Markdown formatting add-ins: format_rmd, rmd_code_block, rmd_list


Format text as R Markdown headings.

Description

RStudio add-ins to format text as R Markdown headings.

Usage

rmd_b_heading_1()

rmd_b_heading_2()

rmd_b_heading_3()

rmd_b_heading_4()

rmd_b_heading_5()

rmd_b_heading_6()

rmd_b_heading_01a_title()

rmd_b_heading_01b_subtitle()

Format text as R Markdown list.

Description

RStudio add-ins which convert text into R Markdown lists. For the first-level lists:

  • rmd_list() - the main function, that make lists;

  • rmd_unordered_list() - unordered list;

  • rmd_numbered_list() - numbered list;

  • rmd_lettered_list() - lettered list (non-capital English letters);

  • rmd_master_list() - master list (which numbering continues throughout the document).

Usage

rmd_list(type = "unordered", level = 1, context = get_context())

rmd_block_quotes()

rmd_line_blocks()

rmd_list_unordered()

rmd_list_unordered_2()

rmd_list_numbered()

rmd_list_numbered_2()

rmd_list_lettered()

rmd_list_lettered_2()

rmd_list_z_example_list()

Arguments

type

(character) the type of list "unordered", "numbered", "lettered", "LETTERED", "master".

level

(integer) the level of list.

context

Object with context of active R Studio document (class document_context).

See Also

Other R Markdown formatting add-ins: format_rmd, rmd_code_block, rmd_equations


Insert R Markdown tables

Description

Insert examples of R Markdown tables.

Usage

rmd_table_1()

rmd_table_2()

rmd_table_3()

rmd_table_4()

rmd_table_5()

Enclose selection with lines.

Description

Enclose selected rows with lines above and below:

  • rs_enclose_all_with_lines() - all selected rows;

  • rs_enclose_first_row_with_lines() - the first selected row only.

Usage

rs_enclose_all_with_lines(above = NA, below = NA,
  ensure_blank_above = FALSE, context = get_context())

rs_enclose_first_row_with_lines(above = NULL, below = NULL,
  ensure_blank_above = FALSE, context = get_context())

Arguments

above

(character) Text to be inserted in the row above the selection.

below

(character) Text to be inserted in the row below the selection (or the first row).

ensure_blank_above

(logical) If TRUE, checks if there is a blank line above the selection. If line is not blank, a blank line is added. If FALSE, blank line is not added.

context

Object with context of active R Studio document (class document_context).


Enclose selection of text with indicated symbols.

Description

Enclose selection of text with certain symbols which usually have special meaning in R Markdown files.

Usage

rs_enclose_selection_with(symbol = "", symbol_before = symbol,
  symbol_after = symbol, context = get_context())

Arguments

symbol

(character) A sequence of symbols to add on both sides of selection.

symbol_before

(character) A sequence of symbols to before the selection (overrides value of symbol).

symbol_after

(character) A sequence of symbols to add after the selection (overrides value of symbol).

context

Object with context of active R Studio document (class document_context).

Details

If text is selected, the cursor is placed after the modified selection. If no text is selected, the cursor is placed between the inserted symbols.


Get indices from the selection.

Description

Get index of the first/last row/column in the selection.

Usage

rs_get_ind_first_selected_col(context = get_context())

rs_get_ind_last_selected_col(context = get_context())

rs_get_ind_first_selected_row(context = get_context())

rs_get_ind_last_selected_row(context = get_context())

Arguments

context

Object with context of active R Studio document (class document_context).


Insert text at the beginning of the row.

Description

Insert text at the beginning of the row.

Usage

rs_insert_at_row_start(row, text = NULL, id = NULL)

Arguments

row

(integer) The index of the row.

text

(character) The text to add.

id

The document id. When NULL or blank, the mutation will apply to the currently open, or last focused, RStudio document. Use the id returned from getActiveDocumentContext() to ensure that the operation is applied on the intended document.


Insert text at the beginning of the first selected row.

Description

Insert text at the beginning of the first selected row.

Usage

rs_insert_before_first_selected_row(text = "",
  ensure_blank_above = FALSE, context = get_context())

Arguments

text

(character) The text to add.

ensure_blank_above

(logical) If TRUE, checks if there is a blank line above/bolow the selection. If line is not blank, a blank line is added. If FALSE, blank line is not added.

context

Object with context of active R Studio document (class document_context).


Insert %in%.

Description

Call this function as an add-in to insert %in% at the cursor position.

Usage

rs_insert_infix_in()

See Also

Operator %in%.

Other 'Insert at cursor position' add-ins: insert_magrittr_operators, rs_insert_infix_R, rs_insert_infix_not_in, rs_insert_matrix_multiplication


Insert %!in%.

Description

Call this function as an add-in to insert %!in% at the cursor position.

Usage

rs_insert_infix_not_in()

Note

Operator does not work unless a package which contains this operator is loaded.

See Also

Operator %in%.

Other 'Insert at cursor position' add-ins: insert_magrittr_operators, rs_insert_infix_R, rs_insert_infix_in, rs_insert_matrix_multiplication


Insert %R%.

Description

Call this function as an add-in to insert %R% at the cursor position.

Usage

rs_insert_infix_R()

Note

Operator does not work unless library which contains this operator is loaded.

See Also

Operator %R% in rebus.

Other 'Insert at cursor position' add-ins: insert_magrittr_operators, rs_insert_infix_in, rs_insert_infix_not_in, rs_insert_matrix_multiplication


Insert %*%.

Description

Call this function as an add-in to insert %*% at the cursor position.

Usage

rs_insert_matrix_multiplication()

See Also

Operator %*% for matrix multiplication.

Other 'Insert at cursor position' add-ins: insert_magrittr_operators, rs_insert_infix_R, rs_insert_infix_in, rs_insert_infix_not_in


Insert a sequence of symbols.

Description

Insert a sequence of symbols.

Usage

rs_insert_symbol_seq(symbol, start_column = 1, end_column = 80)

Arguments

symbol

(character) A sequence of symbols to be repeated

start_column

(integer) Column position where the sequence begins.

end_column

(integer) Column position where the sequence stops.


Replace text in selection.

Description

Replace text in selection.

Usage

rs_replace_in_selection(pattern, replacement, context = get_context())

Arguments

pattern

(character) A fixed pattern of text to be replaced (not a regular expression).

replacement

(character) The replacement text.

context

Object with context of active R Studio document (class document_context).


A Set of RStudio Add-ins.

Description

spAddins provides a set of RStudio add-ins that are designed to be used in combination with user-defined RStudio keyboard shortcuts. These add-ins either insert text at the cursor position (e.g. insert operators %>%, <<-, %$%, etc.), replace symbols in selected pieces of text, e.g., convert back-slashes to forward-slashes or enclose text with special symbols (e.g., converts "bold" into "**bold**") which is convenient for editing R Markdown files.

License: MIT
URL: https://github.com/GegznaV/spAddins
Bug reports and suggestions: https://github.com/GegznaV/spAddins/issues
Author: Vilmantas Gegzna

See Also

Use the links below to learn more about RStudio add-ins and especially how to use them in combination with user-defined keyboard shortcuts:

  1. RStudio add-ins;

  2. Keyboard shortcuts;

  3. Customizing keyboard shortcuts.