Created
May 27, 2015 06:33
-
-
Save briatte/22a60c94d43e8b611f77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(Matrix) | |
## building a 729670 x 1167 object (fast enough) | |
M = list() | |
pb = txtProgressBar(min = 1, max = length(followers_m)) | |
for(i in 1:length(followers_m)) { | |
M[[i]] = as.numeric(userlist %in% followers_m[[i]]) | |
setTxtProgressBar(pb, i) | |
} | |
M = sapply(M, rbind) | |
## SIZE | |
# assembling took a few minutes | |
> dim(M) | |
[1] 729670 1167 | |
> object.size(M) / 10^9 | |
6.81219932 [G]bytes | |
# takes a few minutes | |
> M2 = Matrix(M) | |
> object.size(M2) / 10^9 | |
0.1136096 [G]bytes | |
## NAMING | |
> system.time(colnames(M) <- gsub("followers/|\\.rda", "", filesList)) | |
user system elapsed | |
7.274 20.754 38.679 | |
> system.time(colnames(M2) <- gsub("followers/|\\.rda", "", filesList)) | |
user system elapsed | |
0.004 0.000 0.005 | |
## PRODUCT OF TRANSPOSE (two-mode to one-mode) | |
# takes forever if class(M) = matrix | |
> m = t(M) %*% M | |
> system.time(m <- t(M) %*% M) | |
user system elapsed | |
3.036 0.252 3.299 | |
# oooh yeah | |
# improved network builder by HOURS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment