Possible Duplicate:
R - remove rows with NAs in data.frame
I have a data frame derived from the following function:
complete <- function(directory,id = 1:332) {
csvfiles <- sprintf("/Users/myname/Desktop/%s/%03d.csv", directory, id)
nrows <- sapply( csvfiles, function(f) nrow(read.csv(f)))
rowlabels <- nrow(nrows)
data.frame(id=sprintf('%3d', id),
nobs=sapply(csvfiles,function(x) length(count.fields(x))),
row.names=rowlabels
)
}
This function counts the number of rows in each file contained within the directory produced by the object csvfiles. It then outputs a data frame showing the file number along with the count of rows (so two columns)
Thought I had it but problem is that I must now exclude rows within each file where an instance of NA
exists.
How would I edit this to ignore those rows in each file and just count the rows where no NA
s exist?