Displaying 2 results from an estimated 2 matches for "makea".
Did you mean:
make
2024 Nov 11
0
Matrix - querying dsCMatrix how to save it
...> data-storage (either in file or in a database) for a
> sparse matrix? Thanks in advance!
as that is a relative general question, I allow myself to answer
in public such that the answer my help others as well.
Let's use an example from package 'nadiv':
require(nadiv)
?makeA # to learn about the function
## create a largish example
Awarcol <- makeA(ggTutorial[1:2000, 1:3])
str(Awarcol)
nnzero(Awarcol)
object.size(Awarcol)
object.size(as.matrix(Awarcol)) # ~ 14 times large
image(Awarcol) # wait a bit .. ... but it's worth it!
-------------
> Awarcol <-...
2008 Dec 04
2
How to optimize this codes ?
How to optimize the for-loop to be reasonably fast for sample.size=100000000 ? You may want to change sample.size=1000 to have an idea what I am achieving.
set.seed(143)
A <- matrix(sample(0:1, sample.size, TRUE), ncol=10, dimnames=list(NULL, LETTERS[1:10]))
B <- list()
for(i in 1:10) {
B[[i]] <- apply(combn(LETTERS[1:10], i), 2, function(x) { sum(apply(data.frame(A[,x]), 1,