Skip to contents

Returns the field_period dataset-level metadata key from a survey design object or a data frame.

Usage

extract_field_period(x)

Arguments

x

A survey design object or data.frame.

Value

character(1): the stored field period, or NA_character_ when the key is not set.

Details

Returns the stored field_period only. It never composes a period from field_start and field_end — use extract_field_dates() for those. On a data frame the pre-1.2.0 attribute name dates is read as field_period when no field_period attribute is present. A design object restored from a file written by surveycore 1.1.0 or earlier reports NA_character_ rather than failing.

Examples

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

df <- set_field_period(df, "February-March 2026")
extract_field_period(df)
#> [1] "February-March 2026"