Skip to content

Commit

Permalink
Add documentation regarding dimensionless units (#276)
Browse files Browse the repository at this point in the history
* add note about dimensionless units to documentation

* correct bullet point and add formatting to set_attributes documentation for ease of reading

* add warning about using dimensionless units when unrecognised unit is NA. Resolve #274

* Add test for warning when unit unrecognised

* update pkgdown documentation
  • Loading branch information
annakrystalli authored and cboettig committed May 22, 2019
1 parent 00ee9bc commit 8f95045
Show file tree
Hide file tree
Showing 39 changed files with 1,094 additions and 761 deletions.
62 changes: 38 additions & 24 deletions R/set_attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,56 @@
#' headers shown here. The attributes data frame must contain columns for required metadata.
#' These are:
#'
#' For all data:
#' - attributeName (required, free text field)
#' \strong{For all data:}
#'
#' - attributeDefinition (required, free text field)
#' \itemize{
#' \item attributeName (required, free text field)
#'
#' - measurementScale (required, "nominal", "ordinal", "ratio", "interval", or "dateTime",
#' \item attributeDefinition (required, free text field)
#'
#' \item measurementScale (required, "nominal", "ordinal", "ratio", "interval", or "dateTime",
#' case sensitive) but it can be inferred from col_classes.
#'
#' - domain (required, "numericDomain", "textDomain", "enumeratedDomain", or "dateTimeDomain",
#' \item domain (required, "numericDomain", "textDomain", "enumeratedDomain", or "dateTimeDomain",
#' case sensitive) but it can be inferred from col_classes.
#'
#' For numeric (ratio or interval) data:
#' - unit (required)
#'
#' For character (textDomain) data:
#' - definition (required)
#'
#' For dateTime data:
#' - formatString (required)
#' }
#'
#' \strong{For numeric (ratio or interval) data:}
#' \itemize{
#' \item unit (required). Unitless values should use "dimensionless" as the unit.
#' }
#'
#' \strong{For character (textDomain) data:}
#' \itemize{
#' \item definition (required)
#' }
#'
#' \strong{For dateTime data:}
#' \itemize{
#' \item formatString (required)
#' }
#'
#' Other optional allowed columns in the attributes table are:
#' source, pattern, precision, numberType, missingValueCode, missingValueCodeExplanation,
#' attributeLabel, storageType, minimum, maximum
#'
#' The factors data frame, required for attributes in an enumerated domain, must use only the
#' The \strong{factors} data frame, required for attributes in an enumerated domain, must use only the
#' following recognized column headers:
#' \itemize{
#' \item attributeName (required)
#' \item code (required)
#' \item definition (required)
#' }
#'
#' - attributeName (required)
#' - code (required)
#' - definition (required)
#'
#' The missingValues data frame, optional, can be used in the case that multiple missing value codes
#' The \strong{missingValues} data frame, optional, can be used in the case that multiple missing value codes
#' need to be set for the same attribute. This table must contain the following recognized column
#' headers.
#' \itemize{
#' \item attributeName (required)
#' \item code (required)
#' \item definition (required)
#' }
#'
#' - attributeName (required)
#' - code (required)
#' - definition (required)
#'
#' @return an eml "attributeList" object
#' @export
set_attributes <-
Expand Down Expand Up @@ -130,6 +141,9 @@ set_attribute <- function(row, factors = NULL, missingValues = NULL) {
"' is not a recognized standard unit; treating as custom unit. ",
"Please be sure you also define a custom unit in your EML record, ",
"or replace with a recognized standard unit. ",
ifelse(is.na(row[["unit"]]),
'For unitless values, use "dimensionless" as the unit. ',
NULL),
"See set_unitList() for details."
)
} else {
Expand Down
7 changes: 5 additions & 2 deletions docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions docs/LICENSE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8f95045

Please sign in to comment.