Data-quality flags are stored in the
oce-class objects in a
The present function (a generic that has specialized versions
for various data classes) provides a way to
manipulate the core data based on
the data-quality flags. For example, a common operation is to replace suspicious
or erroneous data with
metadata$flags in the object supplied as the first argument
is empty, then that object is returned, unaltered.
handleFlags analyses the data-quality flags within
the object, in relation to the
flags argument, and interprets
action argument to select an action to be applied to mached
Reasonable defaults are used if
are not supplied (see ‘Details’),
but different schemes are used in different
data archives, so it is risky to rely on these defaults.
It is usually necessary to tailor
to the data and the analysis goals.
1 2 3
An object of
An optional integer specifying the degree of debugging, with
value 0 meaning to skip debugging and 1 or higher meaning to print some
information about the arguments and the data. It is usually a good idea to set
this to 1 for initial work with a dataset, to see which flags are being
handled for each data item. If not supplied, this defaults to the value of
actions are not provided, the
default is to use ARGO flags , in which the
value 1 indicates good data, and other values indicate either unchecked,
suspicious, or bad data. Any data not flagged as good are set
NA in the returned value. Since Argo flag codes run
from 0 to 9, with 1 indicating the highest level of confidence
in the data, the defaults are
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
## Not run: library(oce) data(argo) # 1. Default: anything not flagged as 1 is set to NA, to focus # solely on 'good', in the Argo scheme. argoNew <- handleFlags(argo) # demonstrate replacement, looking at the second profile f <- argo[["salinityFlag"]][,2] # first column with a flag=4 entry df <- data.frame(flag=f, orig=argo[["salinity"]][,2], new=argoNew[["salinity"]][,2]) df[11:15,] ## flag orig new ## 11 1 35.207 35.207 ## 12 1 35.207 35.207 ## 13 4 35.209 NA ## 14 1 35.207 35.207 ## 15 1 35.207 35.207 # 2. A less restrictive case: include also 'questionable' data, # and only apply this action to salinity. argoNew <- handleFlags(argo, flags=list(salinity=4)) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.