You can specify multiple indexes to replace at once, so you can avoid
a for loop entirely like this:
M <- matrix(nrow = 10, ncol = 10)
M[1:4, 5: 6] <- M[5: 6, 1:4] <- m[1, 2]
M[1:4,7] <- M[ 7, 1:4] <- m[1, 3]
M[1:4, 8:10] <- M[8:10, 1:4] <- m[1, 4]
M[5:6,7] <- M[ 7, 5:6] <- m[2, 3]
M[5:
Hi there,
I have a matrix likes:
> m
[,1] [,2] [,3] [,4]
[1,] NA123
[2,]1 NA65
[3,]26 NA4
[4,]354 NA
I hope to expand it to 10 by 10 matrix, M, likes:
> M
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] NA NA NA
Hello,
I am not at all sure that the following answers the question.
The code below ries to find the optimal number of clusters. One of the
changes I have made to your call to kmeans is to subset DMs not dropping
the dim attribute.
library(cluster)
max_clust <- 10
wss <- numeric(max_clust)
Hi Subhamitra,
I think the fact that you are passing a vector of values rather than a
matrix is part of the problem. As you have only one value for each
country, The points plotted will be the index on the x-axis and the
value for each country on the y-axis. Passing a value for ylim= means
that you
4 matches
Mail list logo