as_dataset | R Documentation |
Checks if an object is a valid dataset and returns it with the appropriate
madshapR::class
attribute. This function mainly helps validate inputs
within other functions of the package but could be used separately to check
if a dataset is valid.
as_dataset(object, col_id = NULL)
object |
A potential dataset object to be coerced. |
col_id |
An optional character string specifying the name(s) or position(s) of the column(s) used as identifiers. |
A dataset is a data table containing variables. A dataset object is a data frame and can be associated with a data dictionary. If no data dictionary is provided with a dataset, a minimum workable data dictionary will be generated as needed within relevant functions. Identifier variable(s) for indexing can be specified by the user. The id values must be non-missing and will be used in functions that require it. If no identifier variable is specified, indexing is handled automatically by the function.
A data frame with madshapR::class
'dataset'.
{
# use madshapR_DEMO provided by the package
library(dplyr)
###### Example 1: A dataset can have an id column specified as an attribute.
dataset <- as_dataset(madshapR_DEMO$dataset_MELBOURNE, col_id = "id")
glimpse(dataset)
###### Example 2: Any data frame can be a dataset by definition.
glimpse(as_dataset(iris, col_id = "Species"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.