Skip to contents

Sets the field_period dataset-level metadata key — the field period written for display, such as "February-March 2026" — on a survey design object or a data frame.

Usage

set_field_period(x, period)

Arguments

x

A survey design object or data.frame.

period

character(1), non-NA, or NULL to delete the key. Omitting it is an error, not a deletion.

Value

The modified object, invisibly.

Details

A convenience wrapper for set_dataset_metadata(x, field_period = period).

The argument is named period because the function name already carries the field_ context; the stored key is field_period. This function never touches the two structured dates — use set_field_dates() for those.

On a data frame, deleting the key also removes the pre-1.2.0 dates attribute, so the deletion is idempotent and a later as_survey() call cannot restore the old value.

Examples

df <- data.frame(id = 1:5, y = c(2, 4, 3, 5, 1), w = rep(1, 5))
df <- set_field_period(df, "February-March 2026")
extract_field_period(df)
#> [1] "February-March 2026"

d <- as_survey(df, weights = w)
d <- set_field_period(d, "Spring 2026")
extract_field_period(d)
#> [1] "Spring 2026"