Skip to content

Instantly share code, notes, and snippets.

@phelrine
Created July 14, 2011 18:29
Show Gist options
  • Save phelrine/1083079 to your computer and use it in GitHub Desktop.
Save phelrine/1083079 to your computer and use it in GitHub Desktop.
filter
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