Problems with RStudio and Windows 10?

Hi,
I want to work with RStudio on Windows 10. And read in some excel table with read_xl function. That works and I can take a view.

Now I want to declare them as a network (as.network) from statnet. But then this error comes on: Error: Subscript cbind(i, i) is a matrix, it must be of type logical.

If I do the same things on a different computer with Windows 7, it worked. Can anyone help me??

Best regards!

Hi @Nane,
Looks like {statnet} requires input to be a data matrix (containing only 0,1; and with zeros on the diagonal). You haven't given us any data to check but I suspect that the read_xl() function has returned a dataframe which must be converted to a matrix first:

library(statnet)
new.mat <- data.matrix(your_df)
diag(new.mat) <- 0
g <- network(new.mat, directed=FALSE)
summary(g)

HTH

Thank you a lot for your answer @DavoWW!

The excel file I used is a matrix containing only 0,1) and on my older computer (using Windows 7) the exactly same script is working.
My commends:
WissOperativeAnpass1 <- read_excel("WissOperativeAnpass.xlsx")
NetWissOperativeAnpass1 <- as.network(WissOperativeAnpass1)
summary(NetWissOperativeAnpass1)

And on my new computer (using windows 10) only this commend doens't work:
NetWissOperativeAnpass1 <- as.network(WissOperativeAnpass1)
Then it says: Error: Subscript cbind(i, i) is a matrix, it must be of type logical.

Now I tried your advise, it worked. But then the facts from my network change. For example density is with the as.network commend: 0.039160... and with your advise: 0.124060...

Can you explain this problem?

Thank you so much!

Now I analyzed with the rlang::last_error() - commend and this came out:

<error/tibble_error_subset_matrix_must_be_logical>
Subscript cbind(i, i) is a matrix, it must be of type logical.
Backtrace:

  1. network::as.network(WissOperativeAnpass1)
  2. network::as.network.default(WissOperativeAnpass1)
  3. network::as.network.matrix(x, ...)
  4. network::network.adjacency(...)
  5. base::diag<-(*tmp*, value = 0)
  6. tibble:::[<-.tbl_df(*tmp*, cbind(i, i), value = 0)
  7. tibble:::tbl_subassign_matrix(x, j, value, j_arg, substitute(value))
  8. tibble:::matrix_to_cells(j, x, j_arg)
    Run rlang::last_trace() to see the full context.

But I don't know how to work with that...

Then I tried to convert my Excel files in CSV files and import them. This worked, but then also the facts like density changes...

I solved it!!!
It was possible to declare the Excel file with as.matrix into a matrix and work with this.

I still don't know why the problem only excists with Windows 10 and not with windows 7, but I solved it. That's ok!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.