tbl_cnt | R Documentation |
Generic implementing of how to create a dplyr::tbl()
connection in order
to use dplyr verbs to interact with the remote database table.
Mostly relevant for DBI connectors.
ConnectorDBI: Uses dplyr::tbl()
to create a table reference to a table in a DBI connection.
ConnectorFS: Uses read_cnt()
to allow redundancy between fs and dbi.
tbl_cnt(connector_object, name, ...)
## S3 method for class 'ConnectorDBI'
tbl_cnt(connector_object, name, ...)
## S3 method for class 'ConnectorFS'
tbl_cnt(connector_object, name, ...)
connector_object |
Connector The connector object to use. |
name |
character Name of the content to read, write, or remove. Typically the table name. |
... |
Additional arguments passed to the method for the individual connector. |
A dplyr::tbl object.
# Use dplyr verbs on a table in a DBI database
cnt <- connector_dbi(RSQLite::SQLite())
iris_cnt <- cnt |>
write_cnt(iris, "iris") |>
tbl_cnt("iris")
iris_cnt
iris_cnt |>
dplyr::collect()
iris_cnt |>
dplyr::group_by(Species) |>
dplyr::summarise(
n = dplyr::n(),
mean.Sepal.Length = mean(Sepal.Length, na.rm = TRUE)
) |>
dplyr::collect()
# Use dplyr verbs on a table
folder <- withr::local_tempdir()
cnt <- connector_fs(folder)
cnt |>
write_cnt(iris, "iris.csv")
iris_cnt <- cnt |>
tbl_cnt("iris.csv")
iris_cnt
iris_cnt |>
dplyr::group_by(Species) |>
dplyr::summarise(
n = dplyr::n(),
mean.Sepal.Length = mean(Sepal.Length, na.rm = TRUE)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.