Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
今、私は3次元の配列を持っています。3次元に200行、200列、24個の「スライス」があります
dim=c(200,200,24)
私が必要としているのは、新しいマトリックスをもたらすスライスの平均です。200 x 200のマトリックスが必要です。値は、適切なスライスを平均した結果です。したがって、行1、列1になる場所では、配列のすべての行1と列1の平均が必要です。
これを行う方法はありますか?
簡単な例を使用した1つの試みを次に示します。
test <- 1:8 dim(test) <- c(2,2,2) , , 1 [,1] [,2] [1,] 1 3 [2,] 2 4 , , 2 [,1] [,2] [1,] 5 7 [2,] 6 8
あなたの答えを得る:
apply(test,c(1,2),mean) [,1] [,2] [1,] 3 5 [2,] 4 6