[R] character -> list

David Andel andel at ifi.unizh.ch
Fri Mar 19 00:47:38 CET 2004


Hi

I have a matrix of type "character" (strangly) and am trying to apply 
the function "aggregate" to it, but unfortunately without success.
It seems to me that aggregate would work, if I only could get rid of the 
quotation marks around each item.

So for a very simple example which looks as my actual data look (of 
course here I put the quotation marks on purpose, but I have no idea 
where they come from in my actual data):

 > x <- matrix(c("a","b","1","a","c","3","b","b","2"), nr=3, byrow=T, 
dimnames=list(1:3, c("type","group","value")))
 > x
   type group value
1 "a"  "b"   "1"
2 "a"  "c"   "3"
3 "b"  "b"   "2"

I can't access the columns the way I think would be necessary for 
aggregate to work:
 > x$type
NULL

And this seems to be the problem:
 > typeof(x)
[1] "character"

I think I would need to have type "list" to be able to apply "aggregate".

How can I accomplish this?

Thanks,
David




More information about the R-help mailing list