| jrepl | R Documentation | 
Replace a columns values with matches in a different dataset. Author: Bryce Chamberlain.
jrepl(
  x,
  y,
  by,
  replace.cols,
  na.only = FALSE,
  only.rows = NULL,
  verbose = FALSE,
  viewalldups = FALSE,
  warn = FALSE
)
| x | Main dataset which will have new values. This data set will be returned with new values. | 
| y | Supporting dataset which has the id and new values. | 
| by | Vector of join column names. A character vector if the names match. A named character vector if they don't. | 
| replace.cols | Vector of replacement column names, similar format as by. | 
| na.only | Only replace values that are NA. | 
| only.rows | Select rows to be affected. Default checks all rows. | 
| verbose | Print via cat information about the replacement. | 
| viewalldups | Set to TRUE to see all duplicates | 
| warn | Set to TRUE to see warnings. | 
x with new values.
df1 = utils::head( sleep )
group.reassign = data.frame( 
  id.num = factor( c( 1, 3, 4 ) ), 
group.replace = factor( c( 99, 99, 99 ) ) 
)
jrepl( 
  x = df1, 
  y = group.reassign, 
  by = c( 'ID' = 'id.num' ), 
  replace.cols = c( 'group' = 'group.replace' ) 
)
# doesn't affect since there are no NAs in group.
jrepl( 
  x = df1,
  y = group.reassign, 
  by = c( 'ID' = 'id.num' ), 
  replace.cols = c( 'group' = 'group.replace' ), 
  na.only = TRUE  
) 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.