I have a large matrix which is divided into several pieces, manipulated 
individually, and saved into RData in disc. After each pieces are done with 
operation, I load them into memory and use rbind to stack them back into 
matrix. however, the rbind is only give me the last two pieces. The following 
code illustrates the problem: 4 pieces of matrix (1000x1000) is created and 
stored in RData; then load them back and rbind them. I would expect mat is of 
4000*1000; however, dim(mat) shows (2000 1000).

Where is my code wrong?

Thanks

## define a pathData directory
pathData='C:'\\data';

points=1000;
data.pfx='rnorm';

rname=paste('row',1:points,sep='');
cname=paste('col',1:points,sep='');

for (i in 1:4) {
    x=rnorm(points^2);
    mat=matrix(data=x,nrow=points,ncol=points);
    rname=paste('row',(points*(i-1)+1):(points*i),sep='');
    rownames(mat)=rname;
    colnames(mat)=cname;
    file.rdata=paste(pathData,'\\',data.pfx,'_',i,'.RData',
            sep='');
    save(list='mat',file=file.rdata,compress=T);
}

mat=NULL;
for (i in 1:4) {
    file.rdata=paste(pathData,'\\',data.pfx,'_',i,'.RData',
            sep='');
    x=load(file.rdata);
    mat=rbind(mat,get(x));
}

### code end here

> dim(mat)
[1] 2000 1000




      
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to