flights_db %>%
filter(str_detect(tailnum, "^N[0-9][A-Z]")) %>%
select(year:day, dep_delay, arr_delay)
Error: str_detect() is not available in this SQL variant
Is it possible to insert in this dplyr chain an SQL string? In this case to solve for the str_detect().
Note: I am aware of the glue_sql(), previously I was using this option, but lately I started to use the dplyr for writing queries.
Most of the SQL dialects (which I am familiar with) are using a syntax similar to WHERE fieldname REGEXP 'pattern'. For this reason the suggested solution most probably won’t work.
flights_db %>%
filter(tailnum == REGEXP ('^N[0-9][A-Z]')) %>%
show_query()
<SQL>
SELECT *
FROM `flights`
WHERE (`tailnum` = REGEXP('^N[0-9][A-Z]'))
But your suggestion put me back on the right path and I found a solution. Thank you.