[R] cbind question
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Mar 27 21:30:32 CET 2004
cbind on vectors/matrices which are not atomic is unsupported: we had a
bug report on that within the last 24 hours (but it seems to be
intentional).
You can just concatenate the lists and add a suitable dimension:
res <- c(ll, sym)
dim(res) <- c(508,2)
if I understand your intentions.
I think. However, *why* do you want to do this? A list of lists would
seem to make more sense, and can be indexed in a similar way.
On Sat, 27 Mar 2004, Han, Hillary wrote:
> Just wonder if there is any suggestions in how to get around this cbind
> error. I created two character lists with identical length. First tried
What is a `character list'?
> combine the lists together with cbind, then convert the lists to matrix,
> and tried again. Both faied. Any fix to merge the two lists/matrices?
Merge? That's what c() does.
> ll<- multiget(ftID, hgu95av2LOCUSID)
> > class(ll)
> [1] "list"
> > sym <- multiget(ftID, hgu95av2SYMBOL)
> > class(sym)
> [1] "list"
> > cbind(sym, ll)
> Error in cbind(...) : cannot create a matrix from these types
> > sym <- as.matrix(multiget(ftID, hgu95av2SYMBOL))
> > ll<- as.matrix(multiget(ftID, hgu95av2LOCUSID))
> > dim(sym)
> [1] 508 1
> > dim(ll)
> [1] 508 1
> > class(sym)
> [1] "matrix"
> > class(ll)
> [1] "matrix"
> > cbind(sym,ll)
> Error in cbind(...) : cannot create a matrix from these types
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list