Re: [R] read csv

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Mon 04 Sep 2006 - 17:36:53 GMT

On Mon, 4 Sep 2006, Georg Otto wrote:

>
> Hi,
>
> I have a csv file where the number of filled columns varies in the
> different rows:
>
> Sun 5-Feb-06,15,,,01:30:00,0:06:00,
> Mon 6-Feb-06,,,,,,
> Tue 7-Feb-06,7,,,00:41:00,0:05:51,
> Wed 8-Feb-06,,,,,,
>
> I would like to use read.table (or whatever is appropriate) to read in
> only those rows that have two or more columns filled. Any hint will be
> appreciated.

See ?read.table is the main hint.

Use read.table(fill=TRUE) and post-process, e.g. by

A <- A[rowSums(!is.na(A)) > 2), ]

-- 
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 Tue Sep 05 03:42:02 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 Thu 07 Sep 2006 - 07:51:18 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.