You probably lost the values ββin var , or the column is not numeric, or there is only one row.
Try to remove missing values ββthat will help in the first case:
sd(dat$var, na.rm = TRUE)
If this does not work, make sure that
class(dat$var)
is "numerical" (second case) and that
nrow(dat)
greater than 1 (third case).
Finally, data is a function in R, so it's better to use a different name, which I made here.
mdsumner
source share