I am trying to calculate the variance of a column from a data frame.I know that there are inbuilt functions var() for calculating the variance but I am not sure how to write a function for variance by passing my data frame column as variable.
var(banknote$Length)*((n-1)/n)
If the vector you’re going to take the variance of is 1-dimensional, as in your case, you can simply do:
This assumes (based on your example) that you don’t want to use the
n/(n-1)correction.