[R] Converting Matrix into List - problem (urgent)
JiHO
jo.lists at gmail.com
Sun Mar 22 18:27:32 CET 2009
On 2009-March-22 , at 13:06 , Nidhi Kohli wrote:
> Thank you so much for the quick reply. Let me explain you what I
> want. I have a data file in the following format:
>
> 0.610251D+00 0.615278D+00 0.583581D+00 0.560295D+00
> 0.501325D+00 0.639512D+00 0.701607D+00 0.544963D+00
> 0.589746D+00 0.648588D+00 0.608216D+00 0.582599D+00
> 0.625204D+00 0.523065D+00 0.627593D+00 0.621433D+00
> 0.733730D+00 0.498495D+00 0.748673D+00 0.591025D+00
> 0.578333D+00 0.564807D+00 0.652199D+00 0.579333D+00
>
> I'm reading this file into a variable named congeneric (see my code)
> and now trying to pick up first 20 values and need these 20 values
> in a list format like
>
> 0.610251D+00 (row 1, col 1)
> 0.615278D+00 (row 1, col 2)
> 0.583581D+00 (row 1, col 3)
> .......
> ........
>
> Can you tell me how can i achieve this? I think i'm pretty close but
> don't know how to remove the Row Name and Col. name from the
> conFirstTwenty list (see my code)
Alternatives:
congeneric <- scan(textConnection("0.610251 0.615278 0.583581 0.560295
0.501325 0.639512 0.701607 0.544963
0.589746 0.648588 0.608216 0.582599
0.625204 0.523065 0.627593 0.621433
0.733730 0.498495 0.748673 0.591025
0.578333 0.564807 0.652199 0.579333"), sep=" ")
# you would use scan with the filename in which the data is, rather
than the textConnection. That's just for the purpose of the
demonstration here.
# possible outputs
congeneric[1:20]
as.list(congeneric[1:20])
for (i in 1:20) {
cat(congeneric[i],"\n")
}
JiHO
---
http://jo.irisson.free.fr/
More information about the R-help
mailing list