[R] substitute column data frame based on name stored in variable in r

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Mon Aug 9 10:26:03 CEST 2021

I would like to recursively select the columns of a dataframe by
strong the names of the dataframe in a vector and extracting one
element of the vector at a time. This I can do with, for instance:
vect = names(df)

The problem is that I would like also to change the values of the
selected column using some logic as in `df$column[df$column == value]
<- new.value`, but I am confused on the syntax for the vectorized
version. Specifically, this does not work:
sub_df[vect[1] == 0] = "No"
What would be the correct approach?
Thank you

More information about the R-help mailing list