Assume I have the following multivariate
x <- MASS::mvrnorm(10, rep(0,3), diag(3))
I want to calculate the overall-mean for different subsets. My attempt as follows:
x_barbar <- NULL k = 1 for(i in 1:5){ x_barbar[i] <- mean(x[k:(k + 1), ]) k = k + 2 }
Another statistic that I am interested in calculating is the overall-mean for observations (1,3,5,7,9) then for observations (2,4,6,8,10)
What is the best and concise way of calculating those two different statistics? your help is appreciated.
https://stackoverflow.com/questions/67341418/how-to-calcuated-overall-mean-in-r May 01, 2021 at 07:09AM
没有评论:
发表评论