I tried norm
, but I think it gives the wrong result. (the norm of c(1, 2, 3)
is sqrt(1*1+2*2+3*3)
, but it returns 6
..
norm(x, type = c("O", "I", "F", "M", "2"))
The default is "O"
.
"O"
, "o"
or "1"
specifies the one norm, (maximum absolute column sum);
"F" or "f" specifies the Frobenius norm (the Euclidean norm of x treated as if it were a vector);
norm(as.matrix(x1),"o")
The result is 6, same as norm(as.matrix(x1))
norm(as.matrix(x1),"f")
The result is sqrt(1*1+2*2+3*3)
So, norm(as.matrix(x1),"f")
is answer.