Skip to contents

Sets the data_name dataset-level metadata key — the display label for this particular dataset — on a survey design object or a data frame.

Usage

set_data_name(x, name)

Arguments

x

A survey design object or data.frame.

name

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, data_name = name).

data_name is usually a short name plus the field period, for example "AAA Ipsos (February-March 2026)". It is independent of survey_name: this function writes data_name and nothing else, and it never reads, fills, or checks survey_name. Use set_survey_name() for the formal name.

Examples

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

# The formal survey name is a separate key and stays unset.
extract_survey_name(df)
#> [1] NA

d <- as_survey(df, weights = w)
d <- set_data_name(d, "Example (March 2026)")
extract_data_name(d)
#> [1] "Example (March 2026)"