Connector | R Documentation |
This R6 class is a general class for all connectors. It is used to define the methods that all connectors should have. New connectors should inherit from this class, and the methods described below should be implemented.
new()
Initialize the connector with the option of adding an extra class.
Connector$new(extra_class = NULL)
extra_class
character Extra class to assign to the new connector.
print()
Print method for a connector showing the registered methods and specifications from the active bindings.
Connector$print()
invisible self.
list_content_cnt()
List available content from the connector. See also list_content_cnt.
Connector$list_content_cnt(...)
...
Additional arguments passed to the method for the individual connector.
A character vector of content names
read_cnt()
Read content from the connector. See also read_cnt.
Connector$read_cnt(name, ...)
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.
R object with the content. For rectangular data a data.frame.
write_cnt()
Write content to the connector.See also write_cnt.
Connector$write_cnt(x, name, ...)
x
The object to write to the connection
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.
invisible self.
remove_cnt()
Remove or delete content from the connector. See also remove_cnt.
Connector$remove_cnt(name, ...)
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.
invisible self.
clone()
The objects of this class are cloneable with this method.
Connector$clone(deep = FALSE)
deep
Whether to make a deep clone.
vignette("customize")
on how to create custom connectors and methods,
and concrete examples in ConnectorFS and ConnectorDBI.
# Create connector
cnt <- Connector$new()
cnt
# Standard error message if no method is implemented
cnt |>
read_cnt("fake_data") |>
try()
# Connection with extra class
cnt_my_class <- Connector$new(extra_class = "my_class")
cnt_my_class
# Custom method for the extra class
read_cnt.my_class <- function(connector_object) "Hello!"
registerS3method("read_cnt", "my_class", "read_cnt.my_class")
cnt_my_class
read_cnt(cnt_my_class)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.