Learn R Programming

SurveyStat (version 1.0.3)

weighted_total: Calculate weighted total

Description

This function calculates the weighted total of a numeric variable. Useful for estimating population totals from survey data.

Usage

weighted_total(data, target_col, weight_col)

Value

Numeric weighted total

Arguments

data

A data.frame containing survey data

target_col

Character string specifying column name for target variable

weight_col

Character string specifying column name containing weights

Examples

Run this code
data <- data.frame(income = c(50000, 75000, 100000), weight = c(1000, 800, 1200))
total_income <- weighted_total(data, "income", "weight")

Run the code above in your browser using DataLab