Skip to content

Conversation

@gumeo
Copy link

@gumeo gumeo commented Apr 14, 2025

Hi

This is a small contribution which is a fix to a problem I ran into.

I had an issue with the SKAT package on TTN with 500K rows and 10K columns. The index returned from the which function can exceed the maximum length of an underlying C array, resulting in an overflow. Using array indices fixes this problem.

Best regards,
Guðmundur Einarsson

@gumeo
Copy link
Author

gumeo commented Apr 22, 2025

Hi again,

Here is a simple example to illustrate the problem:

library(Matrix)

# Create an empty sparse matrix
m <- Matrix(0, nrow = 500000, ncol = 10000, sparse = TRUE)

# Set one element to 10 at a high index position
m[5, 6000] <- 10

# Index error:
ind <- which(m == 10)
m[ind] <- 5

# Fix:
ind <- which(m == 10, arr.ind = TRUE)
m[ind] <- 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant