Type: | Package |
Title: | A Set of RStudio Addins |
Version: | 0.2.0 |
Date: | 2017-12-14 |
Description: | 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. |
URL: | https://github.com/GegznaV/spAddins |
BugReports: | https://github.com/GegznaV/spAddins/issues |
License: | MIT + file LICENSE |
LazyData: | TRUE |
ByteCompile: | TRUE |
Encoding: | UTF-8 |
RoxygenNote: | 6.0.1 |
VignetteBuilder: | knitr |
Depends: | R (≥ 3.2) |
Imports: | rstudioapi, magrittr, stringr, purrr |
Suggests: | knitr, rmarkdown, rebus |
NeedsCompilation: | no |
Packaged: | 2017-12-14 18:42:02 UTC; ViG |
Author: | Vilmantas Gegzna [aut, cre, cph] |
Maintainer: | Vilmantas Gegzna <GegznaV@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2017-12-14 18:50:02 UTC |
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:
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_a_superscript()
rmd_a_subscript()
rmd_a_strikethrough()
See Also
Other R Markdown formatting add-ins: rmd_equations
,
rmd_list
Insert arrow (->, ->>, <-, <<-)
Description
RStudio add-in to insert either ->
, ->>
,
<-
or <<-
at the cursor position.
Usage
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
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 %>%, %<>%, %$% and %T>%
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
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_r_code_block()
- R code block; -
rmd_code_block()
- verbatim code block.
rs_enclose_all_with_lines
- function that adds lines above and below the selection.
Usage
rmd_code_block_r()
rmd_code_block()
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_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_1_title()
rmd_b_heading_2_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)
rmd_list_unordered()
rmd_list_unordered_2()
rmd_list_numbered()
rmd_list_numbered_2()
rmd_list_lettered()
rmd_list_lettered_2()
rmd_master_list()
Arguments
type |
(character) the type of list "unordered", "numbered", "lettered", "LETTERED", "master". |
level |
(integer) the level of list. |
See Also
Other R Markdown formatting add-ins: format_rmd
,
rmd_equations
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)
rs_enclose_first_row_with_lines(above = NA, below = NA)
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). |
Enclose selection of text with indicated symbols
Description
Enclose selection of text with indicated symbols
Usage
rs_enclose_selection_with(symbol = "", symbol_before = symbol,
symbol_after = symbol)
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_after |
(character) A sequence of symbols to add after the selection
(overrides value of |
Get index of the first column in the selection
Description
Get index of the first column in the selection
Usage
rs_get_ind_first_selected_col()
Get index of the first row in the selection
Description
Get index of the first row in the selection
Usage
rs_get_ind_first_selected_row()
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)
Arguments
row |
(integer) The index of the row. |
text |
(character) The text to add. |
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 %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 %*%
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)
Arguments
pattern |
(character) A fixted pattern of text to be replaced (not a regular expression). |
replacement |
(character) The replacement text. |