[R] read csv
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Sep 4 19:36:53 CEST 2006
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 at 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
More information about the R-help
mailing list