[R] Reading first line before using read.table()

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Apr 2 02:32:44 CEST 2012


Hi,

On Sun, Apr 1, 2012 at 8:27 PM, Hurr <hill0093 at umn.edu> wrote:
> So far I have figured out that the following line
> reads our time series files into R OK.
> dtLs$dta <- read.table("C:/TryRRead/datFiles/JFeqfi4h.rta", header = TRUE,
> sep = ",", colClasses = "character")
> But I have to remove a main-title line so
> that the first line is the column titles line.
> This leads to having two sets of data files around when
> we would rather have just one set.
> How can I read just one line from the file to
> get the main title in before using the read.table() call?

Not sure I understand correctly, but would something like this do?

R> title.line <- readLines('file.rta', n=1)
R> dat <- read.table('file.rta', skip=1, header=TRUE, ...)

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact



More information about the R-help mailing list