Re: [R] a question about 'read.table' with or without 'read.table'.(urgent)

2010-08-05 Thread karena

Great! Thank you
-- 
View this message in context: 
http://r.789695.n4.nabble.com/a-question-about-read-table-with-or-without-read-table-urgent-tp2314423p2314450.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] a question about 'read.table' with or without 'read.table'.(urgent)

2010-08-05 Thread John Kane
I believe Wu Gong has given you a solution.  As a note you were probably 
reading in the first two columns as either factors or characters and the last 
one as numeric.  You might want to try it again and then do a str() on the 
resulting data.frame to see what was happening.  

It can be confusing to discover that you have factor rather than character data 
in the data.frame.  :)

--- On Thu, 8/5/10, karena dr.jz...@gmail.com wrote:

 From: karena dr.jz...@gmail.com
 Subject: [R] a question about 'read.table' with or without 
 'read.table'.(urgent)
 To: r-help@r-project.org
 Received: Thursday, August 5, 2010, 12:32 AM
 
 Hi, I've got a quite tricky question.
 I have a txt file, named 'temp.txt', as the following:
 snp1        snp2     
   snp3
 AA           00 
          00
 GG           GG 
          00
 00           AA 
          00
 
 I want to read the file into R. 
 1) when I use 'read.table' without 'header=T' option,
  temp - read.table('temp.txt')
 # I got 
  temp
     V1   V2   V3
 1 snp1 snp2 snp3
 2   AA   00   00
 3   GG   GG   00
 4   00   AA   00
 
 2) If I include the 'header=T' option,
  temp - read.table('temp.txt', header=T, as.is=T)
 # I got
  temp
   snp1 snp2 snp3
 1   AA   00    0
 2   GG   GG    0
 3   00   AA    0
 
 The difference is for 'snp3', we can see, in 1) the values
 for snp3 are all
 '00', while in 2) the values are all '0'. 
    How can I keep the original
 values for snp3 as '00', meanwhile get the 'headers' or say
 the colnames as
 'snp1        snp2     
   snp3'?
 
 thank you very much,
 
 karena
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/a-question-about-read-table-with-or-without-read-table-urgent-tp2314423p2314423.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org
 mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.
 



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] a question about 'read.table' with or without 'read.table'.(urgent)

2010-08-04 Thread Wu Gong

read.table(temp.txt,header=T,colClasses = character)

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/a-question-about-read-table-with-or-without-read-table-urgent-tp2314423p2314445.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.