'How to fix the var(X) is now defunct
I used the following function to find standard error of variables. but when I run the same function now, it is not working.
st.err <- function(x) {
sd(x)/sqrt(length(x))
}
I am getting an error while running this command.
Error in var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = na.rm) : Calling var(x) on a factor x is defunct. Use something like 'all(duplicated(x)[-1L])' to test for a constant vector. Calls: ... std.error -> unlist -> sapply -> lapply -> FUN -> var Execution halted
My Rstudio is up to date, as well as all the packages I use. Could any of you suggest an alternate function to get standard error?
Varadhu
Solution 1:[1]
I had this happen recently when my data source changed. I was running source code on time series data that previously did not have a header row in the .csv file.
The new data source added a header. I removed the header and solved the error for my code. Hope this helps.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | user3280311 |