spAddinsThis vignettes describes a recommended workflow how functions of spAddins package should be used and gives several examples.
Four main steps of recommended workflow can be defined. Step 1 and Step 2 should be repeated only once. Steps 3 and 4 can be repeated as many times as needed.
Package spAddins can be installed from CRAN:
install.packages("spAddins")It can be also installed as a development version from GitHub:
install.packages("devtools")
devtools::install_github("GegznaV/spAddins")To learn how to add user defined RStudio keyboard shortcuts, visit these links: Customizing Keyboard Shortcuts and Keyboard Shorcuts.
For addins which insert text, in either R editor or in R console place a cursor at a position at which the text should be inserted.
For addins which replace text, either in R editor or in R console select a piece of text in which certain symbols should be replaced.
Use your keyboard shortcut to call a desired addin to insert or to replace the text.
%>%When package spAddins is already installed let’s set shortcut Ctrl + Alt + . to call function insertPipeline_Addin() which inserts forward-pipe operator %>% operator at cursor’s position. This operator is in package magrittr thus the package should be loaded first.
library(magrittr)To learn more about the %>% operator type:
?`%>%`Next, place your cursor at a position, where the operator should be inserted. Let’s say, between the name of a data set (iris) and the name of a function (head()):
iris head()Push the shortcut combination Ctrl + Alt + . and as a result the operator is inserted:
iris %>% head()\ with /In the following example conciser having a string "c:\data\".
Again let’s define a new shortcut combination, say Ctrl + Alt + Shift + /, which calls an addin. This time addin function we need is Back2ForwardSlash(). This function replaces backslash (\) with forward slash /. Before the replacement appropriate piece of string must be selected. Thus let’s select all string and push Ctrl + Alt + Shift + /. As a result the string is converted into "c:/data/".