powered by
This function that calculates a weighted variance for a given vector.
wt.var(x, w)
wt.var returns a single value from analysis requested.
wt.var
: a vector of numerical data.
: a vector of equal length to x representing the weights.
x
# Define simple data x = 1:25 # Set of numbers. wt = runif(25) # Some arbitrary weights. # Display variances (unweighted and then weighted). var(x) wt.var(x, wt)
Run the code above in your browser using DataLab