-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathcorr.R
28 lines (25 loc) · 1.11 KB
/
corr.R
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
28
#corr <- function(directory, threshold = 0) {
Threshold = 5
corDataS = rep(1, length(id))
corDataN = rep(1, length(id))
for (k in 1:length(id)){
position = id[k]
fileNum = sprintf("%03d", position)
fileName = paste(directory, fileNum, sep = "")
fileNameType = paste(fileName, ".csv", sep = "")
data <- read.csv(fileNameType)
clData=na.omit(data)
if (nrow(clData) >= threshold){
}
corData[k] = clData[,sulfate, nitrate]
}
cCoeff <- data.frame(fileId, nobs)
return(cCoeff)
#}
## 'directory' is a character vector of length 1 indicating
## the location of the CSV files
## 'threshold' is a numeric vector of length 1 indicating the
## number of completely observed observations (on all
## variables) required to compute the correlation between
## nitrate and sulfate; the default is 0
## Return a numeric vector of correlations