An RKWard plugin that provides a graphical user interface (GUI) for
the base R functions sub() and gsub(). This
tool allows users to perform powerful pattern finding and replacement on
character vectors without needing to write code.
gsub (replace all occurrences) and sub
(replace first occurrence).NA values for both the pattern to find and the replacement
text.ignore.case: For case-insensitive matching.perl: To use the powerful Perl-compatible regular
expression engine.fixed: To treat the pattern as a literal string instead
of a regex.useBytes: For byte-by-byte matching.To install this plugin, you will need R, RKWard, and the
devtools and rkwarddev packages installed.
Install the Package: Finally, install the plugin
package using devtools:
```{r}
local({ ## Preparar require(devtools) ## Computar install_github( repo=“AlfCano/rk.gsub.sub” ) ## Imprimir el resultado rk.header (“Resultados de Instalar desde git”) })
```
Restart RKWard: Close and reopen RKWard. The new plugin will be available in the top menu.
NA.ignore.case, perl, fixed) to
control the matching behavior.esoph DatasetThe esoph dataset has an agegp column with
values like "25-34" and "75+". Let’s clean
this to get just the numbers.
data(esoph)esoph and the agegp column.Global replacement (gsub)[+-] (This regex matches a
plus OR a hyphen)The resulting vector will contain values like "2534" and
"75".
NA ValuesImagine you have a vector with missing values that you want to label clearly.
test_vec <- c("Red", "Blue", NA, "Green")test_vec as the input vector.Unknown in the text
field.The resulting vector will be
[1] "Red" "Blue" "Unknown" "Green".