Pass a data.frame column name to a function
- by Kevin Middleton
I'm trying to write a function to accept a data.frame (x) and a column from it. The function performs some calculations on x and later returns another data.frame. I'm stuck on the best-practices method to pass the column name to the function.
The two minimal examples fun1 and fun2 below produce the desired result, being able to perform operations…