[R] strange read.table results

Daniel Alcock da2 at sanger.ac.uk
Tue Nov 17 18:04:18 CET 2009


Sorry about that, it seems it was a windows encoding problem:

read.table("bfx.txt",fileEncoding="UTF-16");

and it works fine

thanks anyway

Dan

Daniel Alcock
Malaria Genetics (T112)
Wellcome Trust Sanger Institute
Cambridge
CB10 1SA
UK
+44 (0)1223 834244 ext. 4994
"The most exciting phrase to hear in science, the one that heralds new discoveries, is not Eureka! But rather, "hmm.... that's funny...." -- Isaac Asimov


-----Original Message-----
From: Sarah Goslee [mailto:sarah.goslee at gmail.com] 
Sent: 17 November 2009 16:58
To: Daniel Alcock
Cc: r-help at r-project.org
Subject: Re: [R] strange read.table results

My guess is that there's something wrong with your file. You really don't
give us enough information to diagnose the problem, though. An encoding
issue? If you open the file in a plain text editor, what happens? What OS
are you using? Version of R?

When I copy your sample data from the email into a text file, deleting the
blank lines, it opens as expected using read.table() with no additiona
arguments.

Sarah

On Tue, Nov 17, 2009 at 9:43 AM, Daniel Alcock <da2 at sanger.ac.uk> wrote:
> Hi I hope someone can shed some light on this:
>
>
>
> For some reason when I
>
>
>
> read.table("bfx.txt")
>
>
>
> R decides to only give back the first character from each column in each row as one single column.
>
>
>
> Like this:
>
>
>
>    V1
>
> 1   яюr
>
> 2    \n
>
> 3     r
>
> 4     1
>
> 5     0
>
> 6     A
>
> 7     G
>
> 8    \n
>
> 9     r
>
> 10    1
>
> 11    0
>
> 12    T
>
> 13    C
>
> 14   \n
>
>
>
> The data should be:
>
>
>
> rs153410928 153410928 0.98802328 A G
>
> rs153411383 153411383 0.988026211 G A
>
> rs153411809 153411809 0.988028954 A G
>
> rs153411854 153411854 0.988029244 A G
>
> rs153413052 153413052 0.988036959 T C
>
>
>
> so not only is it screwing the data it's also missing the first 3 lines. Is this something I've done? I've tried dos2unix to make sure the files are ok, added colClasses="character", sep=" " etc but with no success.
>
>
>
> I'm just about at the end of my tether right now so any help will be gratefully received!
>
>
>
> Dan
>
>


-- 
Sarah Goslee
http://www.functionaldiversity.org


-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE.




More information about the R-help mailing list