Description Usage Arguments Details Value Author(s)
Free and easy replace elements of a vector based on simple replacement data.frames.
1 2 3 4 5 6 7 8 9 |
input |
A input vector having class 'character', 'numeric', 'integer', 'factor'. |
replacements |
This argument defines how to replace values. The basic structure is a data.frame expected to have the columns f(rom) and t(o). |
interactive |
If true an interactive coding session to add recodigs written to file, otherwise the recoding is done just base on the file leaving it as it is. The interactive coding session presents a table of alternatives. One can either enter a new string defining a new category to which the current value is assigned or just enter a number that selects one of the previous categories. Entering 0 adds the current value as category. Entering ” (just return) ignores the current value. |
tab |
Wheter to print the tab of alternatives/categories in every step. |
class |
The desired class of the output vector. |
reptab |
Wheter to print an overview of replacement tabs. Default TRUE but since it depends on stargazer you might decide turn it off in a batched sequence of replacements to save time or keep the output shorteri. |
Reco will replace the input based on a data.frame either from a file or an data.frame given to the replacements argument. It is basically a wrapper to the dplyr::recode-function that does some previous conversions to guarantee that the format of the file/data.frame matches to the input string. If you specify interactive it can be used to recode interactively by appending values to the file.
If only replacements without input is given, reco will return the replacement data.frame for convenience.
a vector of same class as replaments' 'to' column or specified by the 'class' argument.
Marc Schwenzer
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.