我有一個矩陣列表,我試圖將函數應用於每個矩陣的每一列。自然的方式來做到這一點,我想,就是窩apply在lapply,但是當我這樣做,它給了我一個錯誤: library(hydroGOF) # for the mse function
# Create a vector for comparison
A <- rnorm(10)
# Create a list of matrices to
當我嘗試使用"["對列進行部分重新排序時,值將被交換,但列名不會移動。看到下面的例子: x = data.frame(x1 = c(1,2,3), x2 = c(2,3,4), x3 = c("e","e","e"), x4 = c("f","f","f"))
x
#x1 x2 x3 x4
#1 2 e f
#2 3 e f
#3 4 e f
x[, c(3,4)] = x[, c