MAJOR EDIT
Consider a simple data frame:
df = data.frame(obs.no = 1:10, conc = rnorm(10))
discard.obs.no = 1:5
I want this:
df[df$obs.no %in% discard.obs.no,"conc"] = df[df$obs.no %in% discard.obs.no,"conc"]
To be done using a helper function like that:
change(df[df$obs.no %in% discard.obs.no,"conc"], function(x) 2^x)
Essentially I want to avoid retyping the LHS on RHS of the assignment operator. Why? Because the whole thing becomes unwieldy with complicated filtering.
As the example suggests, the function should change only the filtered data, not return the subset. It should also happen in the background i.e. without reassignment to the original data.frame.
Mutate/transform/within etc. do not do the job, since they print out to the console, necessitating reassignment. Assign does not take parts of data.frames as an argument. Whole thing is a bit of vanity project, but I'm sure there's a viz out there who can do it (:
BONUS: try writing a parser that would shorten it even further to:
change(2^df[df$obs.no %in% 1:5,"conc"])
I.e. figure out which part is the object to be reassigned - left/right of $ or left of [ and between [].