Skip to content
Back to formatted view

Raw Message

Message-ID: <20060209032141.536D71CE304@ws1-6.us4.outblaze.com>
Date: 2006-02-09T03:21:41Z
From: Liz Dem
Subject: List Conversion

Hello,

I have a list (mode and class are list) in R that is many elements long and of the form:
>length(list)
[1] 5778
>list[1:4]
$ID1
[1] "num1"
$ID2
[1] "num2" "num3"
$ID3
[1] "num4"
$ID4
[1] NA

I'd like to convert the $ID2 value to be in one element rather than in two.?? It shows up as c(\"num2\", \"num3\") if I try to use paste(list[2], collapse="").  I need to do this over the length of the entire list, however list2 <- apply(list, 1, paste, collapse="") tells me 'Error in apply : dim(X) must have a positive length'.  dim(list) does not have a positive length, which I think is due to the fact that it's a list and not a matrix or data frame.  

What I want to get is:
>list[1:4]
$ID1
[1] "num1"
$ID2
[1] "num2 num3"
$ID3
[1] "num4"
$ID4
[1] NA

Thanks.
Liz

-- 
___________________________________________________
Play 100s of games for FREE! http://games.mail.com/