Skip to content

Commit

Permalink
Assignment-1-Part-2
Browse files Browse the repository at this point in the history
Solution
  • Loading branch information
Rajesh Subramanian committed Sep 13, 2014
1 parent 920e225 commit fa1319a
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
complete <- function(directory, id = 1:332) {
## 'directory' is a character vector of length 1 indicating
## the location of the CSV files

## 'id' is an integer vector indicating the monitor ID numbers
## to be used

## Return a data frame of the form:
## id nobs
## 1 117
## 2 1041
## ...
## where 'id' is the monitor ID number and 'nobs' is the
## number of complete cases
allFiles <- list.files(path = directory, full.names = TRUE)
selectedData <- data.frame()
completeCases <- data.frame()
nobs <- data.frame();
for (i in id) {
selectedData <- (read.csv(allFiles[i],header=TRUE))
nobs <- sum(complete.cases(selectedData))
completeCases <- rbind(completeCases, data.frame(i,nobs))
}
completeCases
}

0 comments on commit fa1319a

Please sign in to comment.