x1=c(131,125,131,119,136,138,139,125,131,134,129,134,126,132,141,131,135,132,139,132,126,135,134,128,130,138,128,127,131,124,124,133,138,148,126,135,132,133,131,133,133,131,131,138,130,131,138,123,130,134,137,126,135,129,134,131,132,130,135,130,137,129,132,130,134,140,138,136,136,126,137,137,136,137,129,135,129,134,138,136,132,133,138,130,136,134,136,133,138,138)
x2=c(138,131,132,132,143,137,130,136,134,134,138,121,129,136,140,134,137,133,136,131,133,135,124,134,130,135,132,129,136,138,138,134,134,129,124,136,145,130,134,125,136,139,136,134,136,128,129,131,129,130,136,131,136,126,139,134,130,132,132,128,141,133,138,134,134,133,138,145,131,136,129,139,126,133,142,138,135,125,134,135,130,131,137,127,133,123,137,131,133,133)
x3=c(89,92,99,96,100,89,108,93,102,99,95,95,109,100,100,97,103,93,96,101,102,103,93,103,104,100,93,106,114,101,101,97,98,104,95,98,100,102,96,94,103,98,99,98,104,98,107,101,105,93,106,100,97,91,101,90,104,93,98,101,96,93,87,106,96,98,95,99,92,95,100,97,101,90,104,102,92,90,96,94,91,100,94,99,91,95,101,96,100,91)
x4=c(49,48,50,44,54,56,48,48,51,51,50,53,51,50,51,54,50,53,50,49,51,47,53,50,49,55,53,48,54,46,48,48,45,51,45,52,54,48,50,46,53,51,56,49,53,45,53,51,47,54,49,48,52,50,49,53,50,52,54,51,52,47,48,50,45,50,47,55,46,56,53,50,50,49,47,55,50,60,51,53,52,50,51,45,49,52,54,49,55,46)
data <- data.frame(x1,x2,x3,x4)
q523 <- data[1:30,]
My first question is if I run mean command (I want to get the mean vector of each column), I cannot get the desired outcome.
> mean(q523)
[1] NA
Warning message:
In mean.default(q523) : argument is not numeric or logical: returning NA
So I turn to the silly method to get mean vector.
x <- matrix(c(mean(q523$x1), mean(q523$x2), mean(q523$x3), mean(q523$x4)), ncol=1)
S = cov(q523)
(q523[1,] - x) %*% solve(S)
Error in (q523[1, ] - x) %*% solve(S) :
requires numeric/complex matrix/vector arguments
Oops, another error.