[R]  dimension trouble for a matrix
    Erin Hodgess 
    erinm.hodgess at gmail.com
       
    Thu Jul 23 20:12:52 CEST 2009
    
    
  
Dear R People:
I'm having trouble with something that should be very simple.
I'm setting up a matrix outside of a loop and writing items into it
during the loop.
Here is the output:
> glob3b("sites.info")
dim 27 3
[1] "/raid1/osg-app"
Error in xy[i, ] : incorrect number of dimensions
Here is the function:
> glob3b
function(xx) {
      x.df <- read.table(xx,header=FALSE,as.is=TRUE,sep="\t")
n1 <- nrow(x.df)
xy <- matrix(rep("",n1*3),nrow=n1,ncol=3)
   cat("dim",dim(xy),"\n")
for(i in 1:n1) {
        xz <- paste("globus-job-run ",x.df[i,2]," /bin/sh -c 'echo $OSG_APP'",
	   sep="")
	xw <- system(xz,intern=TRUE)
	if(length(xw)>0) {
	xy[i,1:2] <- x.df[i,1:2]
	print(xw)
	cat(i,xy[i,],"\n")
	cat(i,length(xw),dim(xw),"\n")
	xy[i,3] <- xw	
	}
}
	return(xy)
}
>
I have no idea what's wrong.  This should run like clockwork.  Any
help is much appreciated.  By the way, this is NOT homework!
Thanks,
Sincerely,
Erin
-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com
    
    
More information about the R-help
mailing list