Reading unequal size variables from text file as dataframe in R
I need help reading a text datafile with unformatted variable name in the
following structure:
a_ID = 259412258 494776
a_SID = 2081
a_cor = 434
a_FAT = 25000 50000 75000 100000
125000 150000 175000 200000 225000 250000
275000 300000 325000 350000 375000 400000
425000 450000 475000 500000 525000 550000
575000 600000 625000 650000 675000 700000
725000 750000 775000 800000 825000 850000
875000 900000 925000 950000 975000
a_loc = 2147483647 2147483647 -73356703 -73355202
-73353701 -73352130 -73350632 -73349210 -73347648 -73346229
a_soc = 2147483647 2147483647 272263158
272261759
272260359 272258876 272257473 272256153 272254668 272253346
Each variable is of unequal length and begins with a_ . Extra points for
pulling out certain variables by name.The unequal length can be filled
with NA's. I have tried scan()
x <- scan(file, what=list(NULL, name=character()))
which returns a list with everything as character.Also, x =
read.table(file, header = T, sep = ",") returns a dataframe with a single
variable. I read about rephape split function but I haven't been able to
figure out how to use it in the above case. Any help would be highly
appreciated.
No comments:
Post a Comment