Created
July 14, 2011 18:29
-
-
Save phelrine/1083079 to your computer and use it in GitHub Desktop.
filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
normalize <- function(col) { | |
m <- col - mean(col) | |
v <- var(col) | |
if(v == 0){ | |
return(m) | |
}else{ | |
return(m/sqrt(v)) | |
} | |
} | |
dat <- read.csv('input.csv') | |
row_num <- dim(dat)[1] | |
normalized_data <- matrix(0, ncol = 12, nrow = row_num) | |
for(i in c(1:12)){ | |
normalized_data[, i] <- normalize(dat[[i+3]]) | |
} | |
write(t(normalized_data), "output.csv", ncolumns = 12, sep = ",") | |
## plot(c(1:row_num), normalized_data[,i], type = "l") | |
## par(new = T) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment