Skip to content
Prev 69827 / 398525 Next

how to use list index to get vector

Hi Gabor, thanks a lot. I understand it now. But Andrew's method is
easier for me to understand. Can I extend my question? I have a data
file, every line has such format:
2:102 5:85 ...
The number before colon is data entry index, the number after colon is
data entry value, and other data entries are zero. I use scan to read
them in R and need to separate the index and value to different
vectors. For example:
[1] "2:102" "5:85"
[[1]]
[1] "2"   "102"

[[2]]
[1] "5"  "85"
or
[1] "2" "5"

Is this the simplest way to get the index or value vector?

-Luke
On 5/16/05, Gabor Grothendieck <ggrothendieck at gmail.com> wrote: