I am new to R and I am looking for a way how to remove all rows and columns from a distance matrix which contain NA values. Here is an example:
set.seed(1)
data <- matrix(rpois(n = 400, lambda = 10), nrow = 20, ncol = 20)
rownames(data) <- LETTERS[1:20]
dist_matrix <- dist(data, method = "euclidean")
dist_matrix[sample(1:190, 10)] <- NA
Is there any elegant way to do this? Thank you very much!