[R] read.table question

Robert Baer rbaer at atsu.edu
Fri Dec 9 01:41:51 CET 2011

Hello All,
This works,
results <- read.table("plink.txt",T)

while this doesn't.
results <- read.table("plink.txt")
The T is the value for the second parameter which you show from the help 
file printout you looked at to be header.  Thus, you are writing in short 
results <- read.table("plink.txt", header=T)    # parameters are assigned by 
position when names are not explicit.

Further, you should know that T is a variable with the value TRUE (boolean). 
Most people recommend you write it out to avoid unexpected reassignments of 
the variable T to something other than TRUE.  Thus, you should write:
results <- read.table("plink.txt", header=TRUE)  # this is explicit of what 
works for plink.txt

Finally, by header = TRUE, you are saying that the first row of your file 
contains the column headings for your data which apparently it does if it it 
works.  Hopes this helps you understand the help file which at least you 
took the time to read.  Good on you!


  Make sure your data frame contains columns CHR, BP, and P

What does adding the "T" in read.table do? Which argument does this
correspond to? I tried searching for it but didn't find the answer in:

     read.table(file, header = FALSE, sep = "", quote = "\"'",
                dec = ".", row.names, col.names,
                as.is = !stringsAsFactors,
                na.strings = "NA", colClasses = NA, nrows = -1,
                skip = 0, check.names = TRUE, fill = !blank.lines.skip,
                strip.white = FALSE, blank.lines.skip = TRUE,
                comment.char = "#",
                allowEscapes = FALSE, flush = FALSE,
                stringsAsFactors = default.stringsAsFactors(),
                fileEncoding = "", encoding = "unknown")

Could someone please explain?

[[alternative HTML version deleted]]

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A. T. Still University of Health Sciences
800 W. Jefferson St.
Kirksville, MO 63501
FAX 660-626-2965

More information about the R-help mailing list