[R] Prevent read.table from converting "+" and "-" to 0
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Nov 4 16:15:37 CET 2008
On Tue, 4 Nov 2008, Duncan Murdoch wrote:
> On 11/4/2008 9:08 AM, Daren Tan wrote:
>> I am using read.table("data.txt", sep="\t") to read in a tab-limited text
>> file. However, two columns of data were read wrongly. read.table converts
>> "+" and "-" in the two columns to 0. I have tried setting other parameters
>> but to no avail.
>
> Set the column classes (using the colClasses argument). It is guessing
> numeric, but clearly that's not true.
I don't think any recent version of R (e.g. 2.7.1 and later) does that,
although some earlier versions did on some platforms.
So an even better solution is to update the R involved (as the posting
guide asked...).
--
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
More information about the R-help
mailing list