Description Usage Arguments Value Examples
Find neares match between a vector of observations and a vector of alternatives
1 | find_near(observ_vector, match_vector, n_near = 5)
|
observ_vector |
named vector or value to find a match from 'match_vector'. If the vector has no names function will still work, but the resulting 'period_1_id' variable will be empty. |
match_vector |
named vector which is used to find a nearest match to the 'observ_vector'. |
n_near |
number of the nearest observations to derive a random match. If 'n_near' is greater than 'length(match_vector)', minimum out of two is used to create a sample for selecting a random match value. |
A dataframe with the number of rows equall to the lenght of the 'observ_vector' vector and one mathcing value and its index from the 'match_vector' corresponding to each value afrom the 'observ_vector'.
1 2 3 4 5 6 7 8 | library(dplyr)
library(purrr)
library(glmnet)
library(syntheticpanel)
obs <- setNames(rnorm(5), as.character(1:5))
match_v <- setNames(rnorm(50), as.character(1:50))
find_near(obs, match_v, n_near = 10)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.