[R] read.table
(Ted Harding)
Ted.Harding at nessie.mcc.ac.uk
Fri Feb 25 22:14:55 CET 2005
On 25-Feb-05 Ted Harding wrote:
> On 25-Feb-05 Sean Davis wrote:
>> I have a commonly recurring problem and wondered if folks
>> would share tips. I routinely get tab-delimited text files
>> that I need to read in.
>> In very many cases, I get:
>>
>> > a <- read.table('junk.txt.txt',header=T,skip=10,sep="\t")
>> Error in scan(file = file, what = what, sep = sep, quote = quote,
>> dec = dec, :
>> line 67 did not have 88 elements
>>
>> I am typically able to go through the file and find a single
>> quote or something like that causing the problem, but with a
>> recent set of files, I haven't been able to find such an issue.
>> What can I do to get around this problem? I can use perl, also....
>
> Hi Sean,
>
> This is only a shot in the dark, but your description has reminded
> me of similar messes in files which have been exported from Excel.
>
> What I have often done in such cases, to check (e.g.) the numbers
> of fields in records (using 'awk' on Linux) is on the following
> lines:
>
> cat filename | awk 'BEGIN{FS="\t"} {print NF}' | unique
OOPS!!!
cat filename | awk 'BEGIN{FS="\t"} {print NF}' | uniq
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 25-Feb-05 Time: 21:14:55
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list