有没有办法在dplyr中使用字符串变量作为过滤器参数?例如:
filter(iris,Sepal.Length > 6)
Run Code Online (Sandbox Code Playgroud)
将被取代
string <- 'Sepal.Length > 6'
filter(iris,string)
Run Code Online (Sandbox Code Playgroud)
基本上,我正在寻找整个过滤器字符串作为变量,因为我正在实际创建过滤器字符串.谢谢你的帮助.
Ric*_*ven 17
如果要使用字符串参数进行过滤,则需要使用filter_()而不是filter()
string <- 'Sepal.Length > 6'
filter_(iris, string)
Run Code Online (Sandbox Code Playgroud)
另请注意,建议*_()在编程时使用这些功能.