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
)
Run the code above in your browser using DataLab