R中稀疏(dgCMatrix)矩阵上的列和运算

R中稀疏(dgCMatrix)矩阵上的列和运算,r,sparse-matrix,R,Sparse Matrix,我有一个大的dgCMatrix,称之为d: > str(d) Formal class 'dgCMatrix' [package "Matrix"] with 6 slots ..@ i : int [1:21925262] 15862 14723 9042 31101 753 953 1015 1377 1642 3603 ... ..@ p : int [1:6794881] 0 0 0 0 0 0 0 0 0 1 ... ..@ Dim :

我有一个大的dgCMatrix,称之为d:

> str(d)
Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  ..@ i       : int [1:21925262] 15862 14723 9042 31101 753 953 1015 1377 1642 3603 ...
  ..@ p       : int [1:6794881] 0 0 0 0 0 0 0 0 0 1 ...
  ..@ Dim     : int [1:2] 33538 6794880
  ..@ Dimnames:List of 2
  .. ..$ : chr [1:33538] "MIR1302-2HG" "FAM138A" "OR4F5" "AL627309.1" ...
  .. ..$ : chr [1:6794880] "AAACCCAAGAAACACT-1" "AAACCCAAGAAACCAT-1" "AAACCCAAGAAACCCA-1" "AAACCCAAGAAACCCG-1" ...
  ..@ x       : num [1:21925262] 1 1 1 1 2 1 1 1 1 1 ...
  ..@ factors : list()
当我运行colSums时,我收到以下错误消息

> nU <- colSums(d)
Error in colSums(d) : 'x' must be an array of at least two dimensions

>nU是否已运行
库(矩阵)
?感谢您的快速回复。实际上它现在起作用了。没想到我忘了添加库。对不起,这个错误。非常感谢。您是否运行了
库(矩阵)
?感谢您的快速回复。实际上它现在起作用了。没想到我忘了添加库。对不起,这个错误。谢谢。