On Mon, 9 Aug 2021 10:26:03 +0200 Luigi Marongiu <marongiu.lu...@gmail.com> wrote:
> vect = names(df) > sub_df[vect[1]] > df$column[df$column == value] <- new.value Let's see, an equivalent expression without the $ syntax is `df[['column']][df[['column']] == value] <- new.value`. Slightly shorter, matrix-like syntax would give us `df[df[['column']] == value, 'column'] <- new.value`. Now replace 'column' with vect[i] and you're done. The `[[`-indexing is used here to get the column contents instead of a single-column data.frame that `[`-indexing returns for lists. Also note that df[[names(df)[i]]] should be the same as df[[i]] for most data.frames. -- Best regards, Ivan ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.