View source: R/convert_DEPTH_to_ordered_factor.R
convert_depth_to_ordered_factor | R Documentation |
This function simplifies converting the DEPTH column from class
numeric
, factor
, or character
to an ordered factor,
which is preferred for using the function plot_variables_at_depth()
.
convert_depth_to_ordered_factor(dat.tidy)
dat.tidy |
Data in tidy format, as returned by the function
|
To use the function plot_variables_at_depth()
, DEPTH
must be a factor because DEPTH
is mapped to a discrete color scale.
For the legend to display correctly (e.g. depths arranged from shallow to
deep), DEPTH
must be an ordered factor.
The DEPTH
column may be values that can be coerced to class
numeric
, qualitative descriptors, or a combination of both. A
different level will be assigned to each of the unique values of
DEPTH
. This could cause some confusion when DEPTH
includes
numeric and qualitative values, for example because the level (colour) for
"Surface" will not the same as the level for "2 m").
Qualitative DEPTH
values will be standardized to "Surface",
"Sub-surface", "Middle", and "Bottom". Accepted qualitative DEPTH
values are "Bottom", "bottom", "Middle", "middle", "Sub surface",
"Sub-Surface", Sub-surface", "sub surface", "sub-surface", "Sub", "sub",
"Surface", and "surface". Other values will cause the function to stop with
an error message.
For numeric depths: the smallest value is assigned to the first level, the second smallest value is assigned to the second level, and so on.
For qualitative depths: the assigned order is "Surface" < "Sub-surface" < "Middle" < "Bottom".
Returns dat.tidy
, with the DEPTH
column converted to an
ordered factor.
Danielle Dempsey
Other format:
convert_to_tidydata()
,
format_for_opendata()
,
trim_data()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.