Friday, 15 September 2017

r - Use data.frame in custom function?



Often functions that work with data.frames have the ability to let the user provide a dataset, so that the user can use its columns in a straight forward way. E.g.:



lm(mpg~cyl+gear,data=mtcars)



Instead of using mtcars$cyl in the formula, we can simply use cyl. How can I implement such behavior in custom built functions?


Answer



There are several different techniques for this, described in Standard nonstandard valuation rules.


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...