From Robert.McGehee at geodecapital.com  Fri Oct 21 16:14:33 2005
From: Robert.McGehee at geodecapital.com (McGehee, Robert)
Date: Fri, 21 Oct 2005 10:14:33 -0400
Subject: [Rd] read.table error upon package installation (PR#8230)
Message-ID: <67DCA285A2D7754280D3B8E88EB548020C9466E9@MSGBOSCLB2WIN.DMN1.FMR.COM>

Yes, but only, it seems, if you put quotes around all the fields (not
just the "A B C"). 

Also a note to Excel users, when adding quotes as suggested "A B C" is
saved as """A B C""" which R reads in differently than Excel.

For my purposes though, everyone who needs to edit this file can just do
so in emacs, and putting quotes around the fields is an easy fix. Thanks

Robert

-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] 
Sent: Friday, October 21, 2005 9:59 AM
To: McGehee, Robert
Cc: r-devel at stat.math.ethz.ch
Subject: RE: [Rd] read.table error upon package installation (PR#8230)


On Fri, 21 Oct 2005, McGehee, Robert wrote:

> Thanks for this.
>
> I tried switching the file extension from txt to tab, but it seems to
> still split on whitespace rather than tabs.
>
> My goal is to create a file that is both readable by R and by a
> spreadsheet program, and that may contain white spaces. If
tab-delimited
> separation is not currently supported on load time, a CSV file would
> also be a natural candidate. Unfortunately for me, it seems that R
> expects the CSV file in the 'data' subdirectory to be delimited by
> semi-colons rather than commas (which seems odd and might be worthy of
> mention in the Writing R Extensions Manual), and the particular
> spread-sheet program I use uses commas to delimit CSV files. So, then,
I
> think that I will be unable to use 'data' subdirectory to load this
data
> using data(), but any feedback on this is welcomed.

Using quotes, e.g. "A B C" may work?

>
> Thanks,
> Robert
>
>
> -----Original Message-----
> From: ripley at stats.ox.ac.uk [mailto:ripley at stats.ox.ac.uk]
> Sent: Friday, October 21, 2005 1:58 AM
> To: r-devel at stat.math.ethz.ch
> Cc: R-bugs at biostat.ku.dk
> Subject: Re: [Rd] read.table error upon package installation (PR#8230)
>
>
> What is the R error here?
>
> The default delimiter in read.table is not \t but whitespace, so the
> first
> example has 2 and 3 rows (fine for header=T) and the second has 2 and
4
> rows.
>
> On Fri, 21 Oct 2005 Robert.McGehee at geodecapital.com wrote:
>
>> Upon upgrading to R 2.2.0 on my Windows box, I found that one of my
>> packages no longer compiled, giving this error:
>>
>> Error in read.table(zfile, header =3D TRUE) :
>> 	more columns than column names
>> Execution halted
>>
>> After removing every line of code from my package and still not being
>> able to compile it, I found the error to be related to a .txt file in
> my
>> data directory. I reduced my data file to a very simple example which
>> causes the error, and a nearly identical file which does not cause
the
>> problem.
>>
>> A file with these contents causes the error (I am using \t to
indicate
>> the usual tab delimiter).
>> x	\t	y
>> A B C	\t	DEF
>>
>> However, if I remove one of the spaces between A and B or B and C,
the
>> package compiles fine:
>> x	\t	y
>> A BC	\t	DEF
>>
>> I can only guess that there is some kind of parsing problem when
there
>> is more than one space between tab delimiters.
>
> Looks more like a user misunderstanding of ?data.
>
> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] read.table error upon package installation (PR#8230)
McGehee, Robert