Re: [R] how to skip certain rows when reading data

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 28 Jul 2006 - 16:40:21 EST

On Thu, 27 Jul 2006, jz7@duke.edu wrote:

> Dear all,
>
> I am reading the data using "read.table". However, there are a few rows I
> want to skip. How can I do that in an easy way? Suppose I know the row
> number that I want to skip. Thanks so much!

The easy way is to read the whole data frame and using indexing (see `An Introduction to R') to remove the rows you do not want to retain. E.g. to remove rows 17 and 137

mydf <- read.table(...)[-c(17, 137), ]

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Fri Jul 28 16:46:10 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 29 Jul 2006 - 12:16:36 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.