Description Usage Arguments Examples
Creates a closure of the matchup()
function that stores with the
matchup()
function data for all of its arguments except for its first,
the vector of elements that need to be matched. This allows one to create
quick, 1:1 matching functions that can be reused, akin to Excel's VLOOKUP
or INDEX/MATCH functionality.
1 | createMatchup(matching_data, match_this, to_this)
|
matching_data |
a data frame containing columns matching two things, i.e. the column names you are inputting in the match_this and to_this arguments. |
match_this |
column name of what you want matched (ex. state initials)... |
to_this |
...column name of what you want the above matched to (ex. state names) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | Let's try using createMatchup to create a function that matches US state
initials to state names, like the example for the matchup() function.
Remember, this is how we matched state initials to names before:
\code{matchup(vector_of_state_initials, us_states, "state", "state_name")}
Now let's create a function to do this, called initials_to_names():
\code{initals_to_names <- createMatchup(us_states, "state", "state_name")}
Now, we just need to input the vector_of_state_initials that was the first
argument in the matchup() function above to produce its output when it comes
to matching state names to initials. This:
\code{initials_to_names(vector_of_state_initials)}
Produces the same output as this:
\code{matchup(vector_of_state_initials, us_states, "state", "state_name")}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.