Bangerino

Untitled

May 25th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.54 KB | None | 0 0
  1. correl <- function(prah=0) {
  2.     ret_vec <- vector()
  3.    
  4.     file_ids <- 1:332
  5.     for (file_id in file_ids) {
  6.         filename <- sprintf("%03d.csv")
  7.         file <- read.csv(filename)
  8.         val_entries <- nrow(file[complete.cases(file), ])
  9.  
  10.         if (val_entries >= prah) {
  11.             # file <- read.csv(filename)
  12.             sulf_vec <- file$sulfate
  13.             nitr_vec <- file$nitrate
  14.  
  15.             correlation <- cor(sulf_vec, nitr_vec, na.rm=TRUE)
  16.             append(ret_vec, correlation)
  17.         }
  18.     }
  19.  
  20.     return ret_vec
  21. }
Add Comment
Please, Sign In to add comment