forked from Rabia-Shafiq/R_Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplete.R
More file actions
27 lines (21 loc) · 752 Bytes
/
complete.R
File metadata and controls
27 lines (21 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
## Returns 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
files <- (Sys.glob("specdata//*.csv"));
nobs <- c();
for (index in id) {
file_data <- read.csv(files[index], sep = ",");
complete_cases <- file_data[complete.cases(file_data),];
nobs <- c(nobs, nrow(complete_cases));
}
return(data.frame(cbind(id, nobs)));
}