[R] read a text file with variable number of spaces

From: Gregory Ryslik <rsaber_at_comcast.net>
Date: Thu, 03 Mar 2011 01:44:21 -0500

Hi,

I seem to be having somewhat of an unusual data input problem with some of the data sets I'm working with and want to run a simulation on.

in the first data set I'm looking at, I have a text file where the spacing between columns varies. I've attached a snippet. Is there a way to read this into R? Basically, I want to ignore all the spaces to make new columns. In a slightly different case, I have a long sequence of nucleotides (the letters are always either g,a,t,c). Is there a way to get each letter into it's own column so that I can then use it as a data set?

I'm kind of loathe to program a java/C program to do this if I don't have to and was wondering if a way in R exists for this.

Thanks!
Greg

Case1:

ACE2_YEAST  0.42  0.37  0.59  0.20  0.50  0.00  0.52  0.29  NUC
ACH1_YEAST  0.40  0.42  0.57  0.35  0.50  0.00  0.53  0.25  CYT
ACON_YEAST  0.60  0.40  0.52  0.46  0.50  0.00  0.53  0.22  MIT
ACR1_YEAST  0.66  0.55  0.45  0.19  0.50  0.00  0.46  0.22  MIT
ACT_YEAST   0.46  0.44  0.52  0.11  0.50  0.00  0.50  0.22  CYT
ACT2_YEAST  0.47  0.39  0.50  0.11  0.50  0.00  0.49  0.40  CYT
ACT3_YEAST 0.58 0.47 0.54 0.11 0.50 0.00 0.51 0.26 NUC ACT5_YEAST 0.50 0.34 0.55 0.21 0.50 0.00 0.49 0.22 NUC Case2:
gtacagtacgtacgtacgatcgatctagcatgcatgcatgcatgcta

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 03 Mar 2011 - 06:48:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Mar 2011 - 08:20:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive