[R] Weird error (special character) of read.table

Duncan Murdoch murdoch.duncan at gmail.com
Tue Feb 22 16:56:13 CET 2011


On 22/02/2011 10:43 AM, John Edwards wrote:
> Hi,
>
> I have the following input file.
> $ cat main.txt
> CEL_A CELL_B
> 1 4
> 2 5
> 2 6
>
> Then I run read.table in R.
>
> >  f=read.table('main.txt', header=T, check.names=F, sep='\t')
> >  head(f)
>    \ufeffCEL_A CELL_B
> 1    1      4
> 2    2      5
> 3    2      6
> >  f$CEL_A
> NULL
>
> I'm not sure where the special character \ufeff comes from. Could anybody
> let me know what is the problem?


The Unicode character "\uFEFF" is the "byte-order mark".  This is 
commonly used in Windows systems, not so commonly on others, which tend 
to get confused by it.  You didn't say what system you are working on 
and what encoding was used for the file; those are likely both important.

Duncan Murdoch



More information about the R-help mailing list