KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to access and assign single slots of an m*n matrix inside a for loop. The code so far: rowCount <- 9 similMatrix = matrix(nrow = rowCount - 1, ncol = rowCount) show(similMatrix) for(i in (rowCount - 1)){ for (j in rowCount) if (i == j){ similMatrix[i == j] <- 0; } } show(similMatrix) so if i = j the NA value in the matrix needs to be replaced with 0.
Tags (comma-separated)
Save Edits
Cancel