View source: R/define_variable.R
define_variable | R Documentation |
Define a hymetDP variable
define_variable( L0_flat, local_variable_column = "variable_name", local_variable = NULL, variable_name = local_variable, variable_units = NULL, sample_medium = "Unknown", value_type = "Unknown", is_regular = FALSE, time_support = 0, time_units = "hour", data_type = "Unknown", general_category = "Unknown", no_data = -9999 )
L0_flat |
(tbl_df, tbl, data.frame) The fully joined source L0 dataset, in "flat" format (see details). |
local_variable_column |
(character) Column in |
local_variable |
(character) Reference to a value in the
|
variable_name |
(character) The CUAHSI ODM Controlled Vocabulary name
for the variable that was measured, observed, modeled, etc. Defaults to the
|
variable_units |
(character) The CUAHSI ODM Controlled Vocabulary name
of units of the data values associated with a variable. Defaults to a
column |
sample_medium |
(character) The CUAHSI ODM Controlled Vocabulary name of the medium in which the sample or observation was taken or made. |
value_type |
(character) The CUAHSI ODM Controlled Vocabulary value that indicates how the data value was generated. |
is_regular |
(boolean) Value indicates whether the data values are from
a regularly sampled time series. Choose |
time_support |
(numeric) Numerical value that indicates the time support
(or temporal footprint) of the data values. 0 is used to indicate data
values that are instantaneous. Other values indicate the time over which
the data values are implicitly or explicitly averaged or aggregated. Goes
along with |
time_units |
(character) The CUAHSI ODM Controlled Vocabulary name of
units of the time support. If |
data_type |
(character) The CUAHSI ODM Controlled Vocabulary value that indicates how the value applies over a time interval. |
general_category |
(character) The CUAHSI ODM Controlled Vocabulary value for general category of the data (i.e. Hydrology). |
no_data |
(numeric) Numeric value used to encode when a data value is not available for this variable. DataValues will be reformatted to match this value. |
This function appends columns to the L0_flat
table and
returns the augmented table.
"flat" format refers to the fully joined source L0 dataset in "wide" form with the exception of the core observation variables, which are in "long" form (i.e. using the variable_name, value, unit columns of the observation table). This "flat" format is the "widest" an L1 hymetDP dataset can be consistently spread due to the frequent occurrence of L0 source datasets with > 1 core observation variable.
(tbl_df, tbl, data.frame) An augmented version of the original flat table, with all of the original columns plus one for each of the specified variable values (i.e. variable_name, variable_units, etc.), plus the VariableCode column, with an auto-generated integer value that will become the primary key of the Variables table. Columns are only added the first time the function is run. Subsequent runs append values to the existing columns.
flat <- hymet_L0_flat[1:8] flat <- hymetDP::define_variable( L0_flat = flat, local_variable_column = "variable_name", local_variable = "DSCHRGE_RATE", variable_name = "Discharge", variable_units = "liters per second", sample_medium = "Surface water", value_type = "Derived Value", is_regular = TRUE, time_support = 15, time_units = "minute", data_type = "Continuous", general_category = "Hydrology", no_data = -9999)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.