我有以下matrix
Rho <- structure(c(1, 0.466666666666667, -0.866666666666667, -0.466666666666667, 
-0.333333333333333, 0.466666666666667, 1, -0.6, -0.466666666666667, 
-0.333333333333333, -0.866666666666667, -0.6, 1, 0.333333333333333, 
0.466666666666667, -0.466666666666667, -0.466666666666667, 0.333333333333333, 
1, -0.2, -0.333333333333333, -0.333333333333333, 0.466666666666667, 
-0.2, 1), .Dim = c(5L, 5L), .Dimnames = list(c("SPX Index", "MXE2 Index", 
"USG4TR Index", "FNAR Index", "DBLCMAVL Index"), c("SPX Index", 
"MXE2 Index", "USG4TR Index", "FNAR Index", "DBLCMAVL Index")))
我认为,为了将函数应用于单个矩阵参数(如行和/或列),我必须以多种方式使用mapply()or apply()。
但是,如果我输入
mean(Rho)  
sd(Rho)
这使我返回了单独的函数应用程序:
> mean(Rho)
     SPX Index     MXE2 Index   USG4TR Index     FNAR Index DBLCMAVL Index 
   -0.04000000     0.01333333     0.06666667     0.04000000     0.12000000 
> sd(Rho)
     SPX Index     MXE2 Index   USG4TR Index     FNAR Index DBLCMAVL Index 
     0.7566006      0.6902496      0.7774603      0.6282250      0.5932959 
这不是我想要的:我想要平均值和标准。开发。我的矩阵的所有元素,比如
> mean(mean(Rho))
[1] 0.04
只需一个命令。
有没有办法在不将我的矩阵强制为向量/数字/其他的情况下做到这一点?
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252   
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    
attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     
other attached packages:
 [1] PerformanceAnalytics_1.0.4.4 xts_0.8-6                   
 [3] zoo_1.7-7                    gogarch_0.7-2               
 [5] fastICA_1.1-16               fGarch_2150.81              
 [7] fBasics_2160.81              rmgarch_0.97                
 [9] Matrix_1.0-9                 lattice_0.20-10             
[11] Kendall_2.2                  spd_1.7                     
[13] KernSmooth_2.23-8            rugarch_1.0-11              
[15] Rsolnp_1.12                  truncnorm_1.0-6             
[17] chron_2.3-42                 numDeriv_2012.3-1           
[19] MASS_7.3-18                  RcppArmadillo_0.3.4.2       
[21] Rcpp_0.9.13                  timeSeries_2160.94          
[23] timeDate_2160.95             rcom_2.2-5                  
[25] rscproxy_2.0-5              
loaded via a namespace (and not attached):
[1] boot_1.3-5       grid_2.15.1      stabledist_0.6-4 tools_2.15.1