View source: R/validateSchema.R
| validateSchema | R Documentation |
This function takes a raw schema description and updates values that were
only given as wildcard or implied values. It is automatically called by
reorganise, but can also be used in concert with the getters to debug
a schema.
validateSchema(schema = NULL, input = NULL)
schema |
[ |
input |
[ |
The core idea of a schema description is that it can be written in a
very generic way, as long as it describes sufficiently where in a table
what variable can be found. A very generic way can be via using the
function .find to identify the initially unknown
cell-locations of a variable on-the-fly, for example when it is merely
known that a variable must be in the table, but not where it is.
validateSchema matches a schema with an input table and inserts the
accordingly evaluated positions (of clusters, filters and variables),
adapts some of the meta-data and ensures formal consistency of the schema.
An updated schema description
# build a schema for an already tidy table (tidyTab <- tabs2shift$tidy) schema <- setIDVar(name = "territories", col = 1) %>% setIDVar(name = "year", col = .find(pattern = "period")) %>% setIDVar(name = "commodities", col = 3) %>% setObsVar(name = "harvested", col = 5) %>% setObsVar(name = "production", col = 6) # before ... schema # ... after validateSchema(schema = schema, input = tidyTab)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.