Hi,
I have a text file i would like to read into a list structure in R.
the files is something like that (which might be describe as a list of data frames):
[[1]]
NAME MEM.SHIP
FBgn0037415 FBgn0037415 0.8035441
FBgn0010812 FBgn0010812 0.6579683
FBgn0265351 FBgn0265351 0.6443309
...
[[3]]
NAME MEM.SHIP
FBgn0037227 FBgn0037227 0.9997242
FBgn0040682 FBgn0040682 0.9997242
...
[[9]]
NAME MEM.SHIP
FBgn0026620 FBgn0026620 0.5241095
FBgn0263619 FBgn0263619 0.5420427
FBgn0263353 FBgn0263353 0.9812295
FBgn0037424 FBgn0037424 0.9793901
FBgn0037428 FBgn0037428 0.9779420
FBgn0037430 FBgn0037430 0.9540148
FBgn0004777 FBgn0004777 0.8962534
FBgn0004778 FBgn0004778 0.9810570
...
I would like it to have a list structure like that at the end:
> str(INPUT)
List of 3
$ : Factor w/ 223 levels "FBgn*****",..: 194 129 222 213 42 130 45 131 132 133 ...
$ : Factor w/ 210 levels "FBgn*****",..: 185 109 110 146 171 175 111 17 112 209 ...
$ : Factor w/ 343 levels "FBgn*****",..: 27 296 326 228 229 263 19 39 230 26
I am reading the file in with scan, but I just get a character vector of all the elements together. I was wondering if there is a way to split the text file into a list by the pattern [[.*]] and than extract only the first column from each data frame.
thanks in advance
Assa
Do you have any reason for not using a data.frame? That's a more straightforward data-container imho.
yes i know. I wish I could. I can't change the input files. This is how I got them. I think this is a list structure exported to a text file.
Hello Assa Yeroslaviz!
We believe that this post does not fit the main topic of this site.
Not a bioinformatics question. Please ask StackOverflow
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!