I have a dataframe(df) that looks like this
a| b| c| d| e| f
val1 val2 val3 val4 val5 val6
my list is
list<-c("b","c","d")
I want it so that only b,c, and d run through a function trimws. However it can be anything.
for (i in list) {
assign(df, get(df) %>% trimws (i), envir = .GlobalEnv)}
I tried running this loop but it did not work. I received an error message
Error: unexpected '}' in " assign(df, get(df) %>% trimws (i), envir = .GlobalEnv)}"
At the end of the day i want to run a function specifically in the three columns only and for it to ignore the ones not in the list
question from:
https://stackoverflow.com/questions/66064090/hi-i-would-like-to-run-a-loop-from-a-list-and-have-it-go-through-a-function-one 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…