兄弟们,我得到了这个lil矩阵:
data <- c(1, 0, 2, 0, 4, 3, 3, 0, 1, 1, 0, 0, 2, 0, 4, 0, 1, 0, 0, 0, 1, 0, 0, 1, 8, 0, 3, 0, 5, 2, 0, 0, 0, 0, 0, 0)
matrixData <- matrix(data, nrow = 6, ncol = 6, byrow = TRUE)
diag(matrixData) <- 0 # zeros out the diag of the matrix
lilMatrix = fractions(sweep(matrixData, 2, colSums(matrixData), FUN="/"))`
lilMatrix
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 0 NaN 2/7 0 4/5 1/2
[2,] 3/13 NaN 1/7 1 0 0
[3,] 2/13 NaN 0 0 1/5 0
[4,] 0 NaN 1/7 0 0 1/6
[5,] 8/13 NaN 3/7 0 0 1/3
[6,] 0 NaN 0 0 0 0
我只是想用这些东西替换列[,2]中愚蠢的愚蠢NaN:
articleVector = fractions(c(3/14,2/14, 5/14, 1/14, 2/14, 1/14))
你们都能帮助兄弟吗?