0

I would like to create a squared matrix with 3003 rows an 3003 columns (number of rows in MyData) It worked that the matrix is created and filled with 3003 rows but only 100 columns and I do not get why.

 library(sp)  
 Dists <- matrix(0, nrow=nrow(MyData), ncol = nrow(MyData))

    for(n in 1:nrow(MyData)){
      Dists[n,] <- spDistsN1(pt = c(MyData$lng[n], MyData$lat[n]), 
                             pts =  as.matrix(MyData[,c("lng","lat")]))

Thanks for your help.

Spacedman
  • 89,688
  • 12
  • 125
  • 209
Laura94
  • 1
  • 1

1 Answers1

3

Since you tagged RStudio I assume that you view your data in RStudio using View() (e.g. by clicking on the data object in the right panel of RStudio).

Have a look at this document: Using the Data Viewer

It tells us:

While rows are unbounded, columns are capped at 100. It’s not currently possible to virtualize columns in the same way as rows, and large numbers of columns cause the interface to slow significantly.

However, your matrix will still contain all columns, you can check this with dim(myMatrix)

PhillipD
  • 1,704
  • 1
  • 13
  • 23