powered by
Given a list of i indexes, j indexes, and distances values, we can create a sparse distance matrix for you. Each vector must have the same size.
create_sparse_matrix(i_index, j_index, distances)
a `dgTMatrix` from the `Matrix` library.
A list of i indexes, must be numeric
A list of j indexes, must be numeric
A list of the distance at the i and j index
i_values <- as.integer(1:100) j_values <- as.integer(sample(1:100, 100, TRUE)) x_values <- as.numeric(runif(100, 0, 1)) s_matrix <- create_sparse_matrix(i_values, j_values, x_values)
Run the code above in your browser using DataLab