How can I avoid the transformation into an atomic vector in a matrix r programming

0 votes
I'm scrambling to come up with a solution to my issue. I'm attempting to create a graph that only contains a particular amount of correlation. Since I don't know how to filter with ggraph, I considered changing my matrix's values to a 0 instead. Here's how I move forward:

matrix[matrix== 1] = 0.00 #substitute 0 for 1

Replace any values below 0.27 in matrix[matrix= 0.27] with zero.

The issue is that this turns my vectors into atomic vectors, which obstructs the graph's formation. I wrote some code to replicate the issue:

M1 = as tibble(21,sample(1:3,100),rep=TRUE))

M2 is equal to as.matrix(round(cor(M1[,],method="kendall"),2)

M2[,2] <- 0.09

M2[M2 == 1] <- 0.00

M2[M2 <= 0 .10] <- 0
Jul 5, 2022 in Data Analytics by avinash
• 1,840 points
968 views