-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCorr.R
30 lines (23 loc) · 1020 Bytes
/
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
29
30
unclascorr <- function(directory, threshold = 0) {
id <- 1:332
df <- complete(directory,id)
goodIDs = df[df["nobs"] > threshold, ]$id
df2 <- NULL
for(i in goodIDs) {
#Name file
if(i < 10) {
filename <- paste(directory, "/00", as.character(i),".csv", sep = "")
} else if(i >= 10 && i < 100) {
filename <- paste(directory,"/0", as.character(i),".csv", sep = "")
} else if(i>=100) {
filename <- paste(directory,"/", as.character(i),".csv", sep = "")
}
#Make file connection
con <- file(filename,"r")
df2 <- read.csv(con, header=TRUE)
close(con)
good <- complete.cases(df2)
complete <- df2[good,]
corr(df2[,1], df2[,2])
}
}