Re: [R] Skipping specified rows in scan or read.table

From: jim holtman <jholtman_at_gmail.com>
Date: Wed, 09 Apr 2008 14:53:34 -0400

Read the file in as lines of text (readLines), 'grep' through the character vector and delete the lines you want and then use:

read.table(textConntection(yourvector))

to read the corrected data in.

On 4/9/08, Ravi Varadhan <rvaradhan_at_jhmi.edu> wrote:
> Hi,
>
>
>
> I have a data file, certain lines of which are character fields. I would
> like to skip these rows, and read the data file as a numeric data frame. I
> know that I can skip lines at the beginning with read.table and scan, but is
> there a way to skip a specified sequence of lines (e.g., 1, 2, 10, 11, 19,
> 20, 28, 29, etc.) ?
>
>
>
> If I read the entire data file, and then delete the character fields, the
> values are still kept as factors, with each value denoted by its level.
> Since, I have continuous variables, there are as many levels as there are
> values. I am unable to coerce this to "numeric" mode. Is there a way to do
> this so that I can then manipulate the numeric data frame?

>
>
>
> Thanks for any help.
>
> Best,
>
> Ravi.
>
> ----------------------------------------------------------------------------
> -------
>
> Ravi Varadhan, Ph.D.
>
> Assistant Professor, The Center on Aging and Health
>
> Division of Geriatric Medicine and Gerontology
>
> Johns Hopkins University
>
> Ph: (410) 502-2619
>
> Fax: (410) 614-9625
>
> Email: rvaradhan_at_jhmi.edu
>
> Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
>
>
>
> ----------------------------------------------------------------------------
> --------
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

______________________________________________
R-help_at_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.
Received on Wed 09 Apr 2008 - 18:55:50 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 Apr 2008 - 19:30:27 GMT.

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

list of date sections of archive