All,
I am trying to rbind a series of matrices into a larger
one. The column order of the small macrices varies (not
a problem). The combined large matrix is to have a subset
of the various small matrix columns. The problem arises when
one of the small matrices does NOT have one of the
columns required for the large combined matrix. Depending
on which column is missing in any(each) small matrix,
I want to cbind a dummy column with the appropriate name
to the input small matrix. The values in the dummy column
vary (NA,2,9) depending upon which column(s) are missing.
The following code contains the problem. This code is
taken from within a for loop which steps through each of
the small input matrices. At this point in the code, "junk"
contains the one of the input small matrices. "keepall" is an
array of charcter names which is desired for the output matrix.
ok_match(keepall,dimnames(junk)[[2]])
#
# If any columns are missing, generate column of NA, 9, or 2 as
appropriate
#
if(any(is.na(ok)))
{
n_nrow(junk)
nas_rep(NA,n)
nines_rep(9,n)
twos_rep(2,n)
bad_(1:length(ok))[is.na(ok)]
for(j in 1:length(bad))
{
if(!is.na(match(keepall[bad[j]],errors)))
junk_cbind(junk,assign(keepall[bad[j]],nines,immediate=T))
else if(!is.na(match(keepall[bad[j]],"tf")))
junk_cbind(junk,assign(keepall[bad[j]],twos,immediate=T))
else
junk_cbind(junk,assign(keepall[bad[j]],nas,immediate=T))
}
}
>From here down the little matrices are "stacked with
something like:
datafile_cbind(datafile,junk[,keepall])
The problem is that while the appropriate "assign" statement does
indeed generate a variable with the appropriate name, none of the
cbind statements work. My guess is that "immediate=T" needs to be
replaced with some other option setting, but nothing I have tried
seems to work.
Any suggestions greatly appreciated,
thx,
bob
key@princeton.edu
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|