# NOT RUN {
my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
d <- dbi_copy_to(my_db, 'd',
data.frame(AUC = 0.6, R2 = 0.2))
eqn <- extend_se(d, c("v" := "AUC + R2", "x" := "pmax(AUC,v)"))
cat(format(eqn))
sql <- to_sql(eqn, my_db)
cat(sql)
DBI::dbGetQuery(my_db, sql)
# SQLite can not run the following query
eqn2 <- extend_se(d, "v" := "rank()",
partitionby = "AUC", orderby = "R2")
sql2 <- to_sql(eqn2, my_db)
cat(sql2)
DBI::dbDisconnect(my_db)
# }
Run the code above in your browser using DataLab