Skip to contents

This function determines the behaviour to adopt when tagged variables of a linelist are lost e.g. through subsetting. This is achieved using options defined for the linelist package. The function can be used in isolation, but it can also accept a dataset as first argument, so that it can be used in pipelines as well.

Usage

lost_tags_action(
  x = NULL,
  action = c("warning", "error", "none"),
  quiet = FALSE
)

get_lost_tags_action()

Arguments

x

either a character, or an optional linelist object; if a character, it needs matching warning (default), error or none (see below)

action

a character indicating the behaviour to adopt when tagged variables have been lost: "error" (default) will issue an error; "warning" will issue a warning; "none" will do nothing

quiet

a logical indicating if a message should be displayed; only used outside pipelines

Value

if a a linelist is provided, it returns the object unchanged; otherwise, returns NULL; the option itself is set in options("linelist")

Author

Thibaut Jombart thibaut@data.org

Examples

# reset default - done automatically at package loading
lost_tags_action()
#> Lost tags will now issue a warning.

# check current value
get_lost_tags_action()
#> [1] "warning"

# change to issue errors when tags are lost
lost_tags_action("error")
#> Lost tags will now issue an error.
get_lost_tags_action()
#> [1] "error"

# change to ignore when tags are lost
lost_tags_action("none")
#> Lost tags will now be ignored.
get_lost_tags_action()
#> [1] "none"

# reset to default: warning
lost_tags_action()
#> Lost tags will now issue a warning.