Supports bquote() .()-style name abstraction including .(-) notation to promote strings to names (please see here: https://github.com/WinVector/rquery/blob/master/Examples/Substitution/Substitution.md).

select_rows(source, expr, env = parent.frame())

select_rows_nse(source, expr, env = parent.frame())

Arguments

source

source to select from.

expr

expression to select rows.

env

environment to look to.

Value

select rows node.

Examples


if (requireNamespace("DBI", quietly = TRUE) && requireNamespace("RSQLite", quietly = TRUE)) {
  my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
  d <- rq_copy_to(my_db, 'd',
                   data.frame(AUC = 0.6, R2 = 0.2, z = 3))
  TARGETCOL = as.name("AUC")
  optree <- select_rows(d, .(TARGETCOL) >= 0.5) %.>%
    select_columns(., "R2")
  cat(format(optree))
  sql <- to_sql(optree, my_db)
  cat(sql)
  print(DBI::dbGetQuery(my_db, sql))
  DBI::dbDisconnect(my_db)
}
#> mk_td("d", c(
#>   "AUC",
#>   "R2",
#>   "z")) %.>%
#>  select_rows(.,
#>    AUC >= 0.5) %.>%
#>  select_columns(., 
#>     c('R2'))
#> SELECT
#>  `R2`
#> FROM (
#>  SELECT * FROM (
#>   SELECT
#>    `AUC`,
#>    `R2`
#>   FROM
#>    `d`
#>  ) tsql_28116458073859186234_0000000000
#>  WHERE `AUC` >= 0.5
#> ) tsql_28116458073859186234_0000000001
#>    R2
#> 1 0.2