fst_use_svydesign: Add 'svydesign' weights to CoNLL-U data

View source: R/02_data_exploration.R

fst_use_svydesignR Documentation

Add 'svydesign' weights to CoNLL-U data

Description

This function takes data in CoNLL-U format and a 'svydesign' (from 'survey' package) object with weights in it and merges the weights, and any additional columns into the formatted data.

Usage

fst_use_svydesign(data, svydesign, id, add_cols = NULL, add_weights = TRUE)

Arguments

data

A dataframe of text in CoNLL-U format, with optional additional columns.

svydesign

A 'svydesign' object containing the raw data which produced the 'data'

id

ID column from raw data, must match the 'docid' in formatted 'data'

add_cols

Optional, a column (or columns) from the dataframe which contain other information you'd need (for instance, covariate column for splitting the data for comparison plots).

add_weights

Optional, a boolean for whether to add weights from svydesign object, default is 'TRUE'.

Value

A dataframe of text in CoNLL-U format plus a ''weight'' column and optional other columns

Examples

svy_child <- survey::svydesign(id=~1, weights= ~paino, data = child)
fst_use_svydesign(data = fst_child_2, svydesign = svy_child, id = 'fsd_id')

svy_dev <- survey::svydesign(id = ~1, weights = ~paino, data = dev_coop)
fst_use_svydesign(data = fst_dev_coop_2, svydesign = svy_dev, id = 'fsd_id')

finnsurveytext documentation built on April 4, 2025, 5:07 a.m.