I\'m trying to use a sparse matrix to generate dummy variables for a set of data with 5.8 million rows and two categorical columns.
The structure of the data is:
Try this:
spmat<-Matrix(0,nrow = 210000 ,ncol = 500,sparse = T) locs<-Matrix(data=c(mydata$Var_1,mydata$Var_2),byrow=F,ncol=2) spmat[locs]=1