Is there a way to use a string variable as the filter argument in dplyr? For example:
filter(iris,Sepal.Length > 6)
would be replaced with
string <- 'Sepal.Length > 6'
filter(iris,string)
Basically, I am looking for the entire filter string to be a variable as I am creating the filter string pragmatically. Thanks for any help.
If you want to filter with a string argument, you'll need to use filter_()
instead of filter()
string <- 'Sepal.Length > 6'
filter_(iris, string)
Also note that it's recommended to use the *_()
functions when programming.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With