[R] apply
Ivan Krylov
|kry|ov @end|ng |rom d|@root@org
Fri Oct 4 13:28:29 CEST 2024
В Fri, 4 Oct 2024 19:14:30 +0800
Steven Yen <styen using ntu.edu.tw> пишет:
> I have a vector:
> set.seed(123) > n<-3 > x<-rnorm(n); x [1] -0.56047565 -0.23017749
> 1.55870831
> var(x[1]) cov(x[1],x[2])
Are you sure you don't have a matrix? If you type var(x[1]) or
cov(x[1],x[2]) into R, you can see that all these are NA: an unbiased
estimate of variance or covariance requires dividing by (sample size -
1), which would be 0 for individual numbers.
Even if you did divide by (sample size), the answers would all be 0,
because a single number is always equal to the mean of the same one
number.
--
Best regards,
Ivan
More information about the R-help
mailing list