| Title: | R Interface to 'Dask' |
|---|---|
| Description: | Run 'dplyr' verbs on 'Dask' data frames from R. Connect to a local 'Dask' client or a remote scheduler, copy R data frames onto the cluster, read and write Parquet and CSV, and collect results as 'tibble' objects. Computation stays in Python workers through 'reticulate'; R only builds the graph. A Python installation with the 'dask' package is required. |
| Authors: | Louis Li [aut, cre, cph] |
| Maintainer: | Louis Li <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-10-15 20:39:28 UTC |
| Source: | https://github.com/cran/dasklyr |
dplyr dplyr::copy_to() method for dask_connection. Counterpart to
sparklyr's copy_to.spark_connection. There is no dask_copy_to();
use the dplyr generic, same as sparklyr.
## S3 method for class 'dask_connection' copy_to( dest, df, name = deparse(substitute(df)), overwrite = FALSE, memory = FALSE, repartition = 1L, ... )## S3 method for class 'dask_connection' copy_to( dest, df, name = deparse(substitute(df)), overwrite = FALSE, memory = FALSE, repartition = 1L, ... )
dest |
A |
df |
A |
name |
Table name in the registry. |
overwrite |
If |
memory |
If |
repartition |
Number of Dask partitions. Same argument name as
sparklyr (not |
... |
Unused. |
Named tables live in a client-side registry (sc$tables), not a Hive
catalog. Retrieve them with dplyr::tbl().
A tbl_dask.
## Not run: sc <- dask_connect() iris_tbl <- copy_to(sc, iris, "iris", overwrite = TRUE) ## End(Not run)## Not run: sc <- dask_connect() iris_tbl <- copy_to(sc, iris, "iris", overwrite = TRUE) ## End(Not run)
Checks that reticulate can start Python and import dask.dataframe.
Honors DASKLYR_PYTHON if set.
dask_available()dask_available()
TRUE or FALSE.
## Not run: dask_available() ## End(Not run)## Not run: dask_available() ## End(Not run)
Counterpart to sparklyr's spark_config(). Values are stored on the
connection object returned by dask_connect().
dask_config(...)dask_config(...)
... |
Named options. Known keys:
|
A named list.
dask_config(timeout = 30)dask_config(timeout = 30)
Counterpart to sparklyr's spark_connect(master = ...). With no
arguments, starts a local client. DASK_SCHEDULER is not read here;
pass master (or dask_connect(Sys.getenv("DASK_SCHEDULER"))) for a
cluster.
dask_connect( master = "local", app_name = "dasklyr", config = dask_config(), timeout = NULL, processes = NULL, scheduler = NULL, ... )dask_connect( master = "local", app_name = "dasklyr", config = dask_config(), timeout = NULL, processes = NULL, scheduler = NULL, ... )
master |
|
app_name |
Application name used when reusing connections. |
config |
A list from |
timeout |
Seconds to wait when connecting to a remote scheduler. |
processes |
Passed to |
scheduler |
Alias for |
... |
Unused; present for sparklyr-like call compatibility. |
The same master + app_name pair reuses an open connection.
A dask_connection.
## Not run: sc <- dask_connect(master = "local") sc <- dask_connect(master = Sys.getenv("DASK_SCHEDULER")) ## End(Not run)## Not run: sc <- dask_connect(master = "local") sc <- dask_connect(master = Sys.getenv("DASK_SCHEDULER")) ## End(Not run)
Counterpart to sparklyr's spark_connection_find().
dask_connection_find(master = NULL, app_name = NULL)dask_connection_find(master = NULL, app_name = NULL)
master |
Scheduler address, or |
app_name |
Application name. |
A list of matching dask_connection objects (possibly empty).
dask_connection_find()dask_connection_find()
Is a Dask connection still usable?
dask_connection_is_open(sc)dask_connection_is_open(sc)
sc |
A |
TRUE or FALSE.
dask_connection_is_open(NULL)dask_connection_is_open(NULL)
Counterpart to sparklyr's spark_dataframe(). Returns the Python object
so you can call APIs that dasklyr has not wrapped.
dask_dataframe(x)dask_dataframe(x)
x |
A |
A reticulate Python Dask DataFrame.
## Not run: sc <- dask_connect() st <- copy_to(sc, mtcars, overwrite = TRUE) dask_dataframe(st) ## End(Not run)## Not run: sc <- dask_connect() st <- copy_to(sc, mtcars, overwrite = TRUE) dask_dataframe(st) ## End(Not run)
Counterpart to sparklyr's spark_disconnect().
dask_disconnect(sc, ...)dask_disconnect(sc, ...)
sc |
A |
... |
Unused. |
sc, invisibly.
## Not run: sc <- dask_connect() dask_disconnect(sc) ## End(Not run)## Not run: sc <- dask_connect() dask_disconnect(sc) ## End(Not run)
Counterpart to sparklyr's spark_disconnect_all().
dask_disconnect_all(...)dask_disconnect_all(...)
... |
Passed to |
The number of connections closed.
dask_disconnect_all()dask_disconnect_all()
Counterpart to sparklyr's invoke(): call a method on a Dask DataFrame
or on the distributed Client. If the result looks like a Dask DataFrame
it is wrapped as a tbl_dask.
dask_invoke(x, method, ...) ## S3 method for class 'tbl_dask' dask_invoke(x, method, ...) ## S3 method for class 'dask_connection' dask_invoke(x, method, ...)dask_invoke(x, method, ...) ## S3 method for class 'tbl_dask' dask_invoke(x, method, ...) ## S3 method for class 'dask_connection' dask_invoke(x, method, ...)
x |
A |
method |
Python method name. |
... |
Arguments forwarded to the Python method. |
A tbl_dask if the Python result looks like a Dask DataFrame;
otherwise the value returned by reticulate.
## Not run: sc <- dask_connect() st <- copy_to(sc, mtcars, overwrite = TRUE) dask_invoke(st, "npartitions") ## End(Not run)## Not run: sc <- dask_connect() st <- copy_to(sc, mtcars, overwrite = TRUE) dask_invoke(st, "npartitions") ## End(Not run)
Counterpart to sparklyr's spark_read_csv() / spark_read_parquet().
Signature is (sc, name, path): name may be omitted and is then derived
from the path.
dask_read_parquet( sc, name = NULL, path = name, memory = FALSE, overwrite = TRUE, ... ) dask_read_csv( sc, name = NULL, path = name, memory = FALSE, overwrite = TRUE, ... )dask_read_parquet( sc, name = NULL, path = name, memory = FALSE, overwrite = TRUE, ... ) dask_read_csv( sc, name = NULL, path = name, memory = FALSE, overwrite = TRUE, ... )
sc |
A |
name |
Name to register on |
path |
File or glob. Defaults to |
memory |
If |
overwrite |
If |
... |
Extra arguments forwarded to |
path must be visible to workers. A Windows tempfile() is fine for
master = "local"; it is not usable from a Docker cluster unless the
path is a shared volume or object store.
A tbl_dask.
## Not run: sc <- dask_connect() pq <- dask_read_parquet(sc, "sales", "/data/sales.parquet") ## End(Not run)## Not run: sc <- dask_connect() pq <- dask_read_parquet(sc, "sales", "/data/sales.parquet") ## End(Not run)
Counterpart to sparklyr's spark_web().
dask_web(sc, browse = interactive())dask_web(sc, browse = interactive())
sc |
A |
browse |
If |
The dashboard URL, invisibly.
## Not run: sc <- dask_connect() dask_web(sc, browse = FALSE) ## End(Not run)## Not run: sc <- dask_connect() dask_web(sc, browse = FALSE) ## End(Not run)
Counterpart to sparklyr's spark_write_parquet() / spark_write_csv().
The destination must be writable from workers.
dask_write_parquet(x, path, mode = NULL, overwrite = FALSE, ...) dask_write_csv(x, path, mode = NULL, overwrite = FALSE, ...)dask_write_parquet(x, path, mode = NULL, overwrite = FALSE, ...) dask_write_csv(x, path, mode = NULL, overwrite = FALSE, ...)
x |
A |
path |
Destination path. |
mode |
|
overwrite |
If |
... |
Extra arguments forwarded to |
x, invisibly.
## Not run: sc <- dask_connect() st <- copy_to(sc, mtcars, overwrite = TRUE) tmp <- tempfile() dask_write_parquet(st, tmp, overwrite = TRUE) dask_write_csv(st, tempfile()) ## End(Not run)## Not run: sc <- dask_connect() st <- copy_to(sc, mtcars, overwrite = TRUE) tmp <- tempfile() dask_write_parquet(st, tmp, overwrite = TRUE) dask_write_csv(st, tempfile()) ## End(Not run)
Counterpart to sparklyr's sdf_* helpers. Names use ddf_* so they are
not mistaken for Spark.
ddf_schema(x) ddf_columns(x) ddf_npartitions(x) ddf_ncol(x) ddf_nrow(x) ddf_dim(x) ddf_repartition(x, npartitions = NULL, partitions = npartitions) ddf_persist(x)ddf_schema(x) ddf_columns(x) ddf_npartitions(x) ddf_ncol(x) ddf_nrow(x) ddf_dim(x) ddf_repartition(x, npartitions = NULL, partitions = npartitions) ddf_persist(x)
x |
A |
npartitions, partitions
|
Number of partitions. |
ddf_nrow() computes (len(ddf)). dim() on a tbl_dask reports
NA rows on purpose; use this when you need the real count.
ddf_columns() a character vector; ddf_npartitions() /
ddf_ncol() / ddf_nrow() integers; ddf_dim() c(nrow, ncol);
ddf_schema() a tibble of name and type; ddf_repartition() /
ddf_persist() the same tbl_dask with an updated Python frame.
## Not run: sc <- dask_connect() st <- copy_to(sc, mtcars, overwrite = TRUE, repartition = 2L) ddf_schema(st) ddf_npartitions(st) ddf_nrow(st) ddf_repartition(st, npartitions = 4L) ## End(Not run)## Not run: sc <- dask_connect() st <- copy_to(sc, mtcars, overwrite = TRUE, repartition = 2L) ddf_schema(st) ddf_npartitions(st) ddf_nrow(st) ddf_repartition(st, npartitions = 4L) ## End(Not run)
A tbl_dask is a lazy Dask DataFrame plus optional grouping columns.
print() and head() preview the first partition (Dask's
DataFrame.head). Use dplyr::slice_head() when you need a global
first-n (that path collects, then wraps the result).
## S3 method for class 'tbl_dask' print(x, n = 6L, ...) ## S3 method for class 'tbl_dask' head(x, n = 6L, ...) ## S3 method for class 'tbl_dask' dim(x) ## S3 method for class 'tbl_dask' colnames(x, ...) ## S3 method for class 'tbl_dask' names(x) ## S3 method for class 'tbl_dask' collect(x, ...)## S3 method for class 'tbl_dask' print(x, n = 6L, ...) ## S3 method for class 'tbl_dask' head(x, n = 6L, ...) ## S3 method for class 'tbl_dask' dim(x) ## S3 method for class 'tbl_dask' colnames(x, ...) ## S3 method for class 'tbl_dask' names(x) ## S3 method for class 'tbl_dask' collect(x, ...)
x |
A |
n |
Number of rows to preview. |
... |
Unused. |
dplyr::collect() computes the full frame, resets the pandas index, and
returns a tibble.
print() and head() return a tibble preview; collect() a
tibble of the full compute; dim() is c(NA, ncol); names() /
colnames() a character vector of column names.
## Not run: sc <- dask_connect() st <- copy_to(sc, mtcars, overwrite = TRUE) names(st) head(st, 3) dplyr::collect(st) ## End(Not run)## Not run: sc <- dask_connect() st <- copy_to(sc, mtcars, overwrite = TRUE) names(st) head(st, 3) dplyr::collect(st) ## End(Not run)
dplyr dplyr::tbl() method for dask_connection.
## S3 method for class 'dask_connection' tbl(src, from, ...)## S3 method for class 'dask_connection' tbl(src, from, ...)
src |
A |
from |
Table name previously passed to |
... |
Unused. |
A tbl_dask.
## Not run: sc <- dask_connect() copy_to(sc, iris, "iris", overwrite = TRUE) tbl(sc, "iris") ## End(Not run)## Not run: sc <- dask_connect() copy_to(sc, iris, "iris", overwrite = TRUE) tbl(sc, "iris") ## End(Not run)