Possible duplicate:
R - delete lines with NA in the data.frame file
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 lines in each file contained in the directory created by the csvfiles object. Then it displays a data frame showing the file number along with the number of rows (so there are two columns)
Thought I had it, but the problem is that now I have to exclude lines in every file where an NA instance exists.
How do I edit this to ignore these lines in every file and just count lines where there is no NA ?
source share