Thanks very much. I used c, and got the two lists merged fine. I would like to
write the results into a file. So used
> write.table(try, file = "try.txt")
Error in cbind(...) : cannot create a matrix from these types
Got into the same cbind error... Any suggestions? Thanks in advance.
code:> > class(ll)
> [1] "list"
> > class(sym)
> [1] "list"
> > dim(sym)
> [1] 508 1
> > dim(ll)
> [1] 508 1
> try <- c(sym[1:5], ll[1:5])
> dim(try)
NULL> dim(try)<- c(5, 2)
> try
[,1] [,2]
[1,] "Slc40a1" 53945
[2,] "Rassf5" 54354
[3,] "Igfbp4" 16010
[4,] "Hmox1" 15368
[5,] "Cxcr4" 12767> write.table(try, file = "try.txt")
Error in cbind(...) : cannot create a matrix from these types
-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]
Sent: Sat 3/27/2004 3:30 PM
To: Han, Hillary
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] cbind question
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