library("rquery")

run_example <- function(db) {
  print("***********")
  print(db)
  d <- rq_copy_to(db, "d",
                   data.frame(v = NA_real_,
                              w = 1,
                              x = c(rev(1:10), NA, NA),
                              y = c(NA, NA, sin(1:10)),
                              z = rev(letters[1:12]),
                              stringsAsFactors = FALSE),
                   temporary = TRUE,
                   overwrite = TRUE)

  optree <- d %.>%
    quantile_node(.) 
  print(optree)

  execute(db, optree) %.>%
    print(.)

  optrees <- d %.>%
    rsummary_node(., quartiles = TRUE) 
  print(optrees)

  execute(db, optrees) %.>%
    print(.)

  rq_remove_table(db, "d")
}

db <- sparklyr::spark_connect(version='2.2.0', 
                                master = "local")
run_example(db)
sparklyr::spark_disconnect(db)



db <- DBI::dbConnect(RPostgreSQL::PostgreSQL(),
                     host = 'localhost',
                     port = 5432,
                     user = 'johnmount',
                     password = '')
run_example(db)
DBI::dbDisconnect(db)

db <- DBI::dbConnect(RPostgres::Postgres(),
                     host = 'localhost',
                     port = 5432,
                     user = 'johnmount',
                     password = '')
run_example(db)
DBI::dbDisconnect(db)


WinVector/rquery documentation built on Aug. 24, 2023, 11:12 a.m.