I've transitioned into writing some user-defined functions in R, but I'm hung up on whether it's best to use a dollar sign or bracket when indexing several data_frame columns. My function is like this, for a conditional value replace:
replacer <- function(df_col1,df_col2 i, k) {
df_col1[df_col2 %in% i] <-k
}
Is there a better way to write this, one that has fewer arguments? With four arguments my way isn't very practical.