Re: [R] read csv

2006-09-04 Thread Prof Brian Ripley
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,  [EMAIL PROTECTED]
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, UKFax:  +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.


Re: [R] read csv

2006-09-04 Thread Thomas Hunger
 I have a csv file where the number of filled columns
 varies in the different rows:

I would hack it like this, but then I am totally new to R, 
which means you should not trust me.:

d - read.csv(testdata, header=F)

selection - apply(d, c(1), 
  function(x) {sum(!is.na(x)  x != )  2})

as.data.frame(t(as.data.frame(t(d))[selection]))


Tom

__
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.