用于 dplyr sql 表的 grepl? [英] grepl for dplyr sql table?

查看:14
本文介绍了用于 dplyr sql 表的 grepl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用类似的东西

is there a workaround to use something like

filter(df, grepl("A|B|C",location))

对于 dplyr SQL 表?在 SQL 中,它可能是 LIKE.当然,我可以将 SQL 表转换为 R 数据表,但它非常大.(http://cran.r-project.org/web/packages/dplyr/vignettes/databases.html) 目前我得到

for a dplyr SQL table? In SQL it is probalby a LIKE. Of cource I could convert the SQL table to a R data table, but it is very large. (http://cran.r-project.org/web/packages/dplyr/vignettes/databases.html) At the moment I get

Error in sqliteSendQuery(conn, statement) : 
  error in statement: no such function: GREPL

谢谢克里斯托夫

推荐答案

使用 sql 将表达式直接翻译成 sql 是一种选择.

Using sql to translate the expression directly into sql is one option.

sql_table %>% filter( sql("location LIKE 'A%' 
                           OR location LIKE 'B%' 
                           OR location LIKE 'C%'")

这会将以下内容注入查询的 WHERE 语句中:

Which will inject the following into the WHERE statement of your query:

<SQL> location LIKE 'A%' OR location LIKE 'B%' OR location LIKE 'C%'

这篇关于用于 dplyr sql 表的 grepl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆