-
-
Save mribeirodantas/2fcaeb5f8e2b692ef5e38053ef658bea to your computer and use it in GitHub Desktop.
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
# Your new preprocess.R should look like this | |
input_file <- read.csv(file = 'data/simulation.tsv', | |
sep='\t', | |
stringsAsFactors=FALSE) | |
input_file <- input_file[, 1:50] | |
input_file <- lapply(input_file, | |
function(x) replace(x, | |
is.na(x), | |
mean(x, | |
na.rm = TRUE))) | |
input_file <- as.data.frame(input_file) | |
input_file[, unlist(lapply(input_file, is.numeric))] <- | |
apply(input_file[, unlist(lapply(input_file, is.numeric))], | |
2, | |
function(x) ifelse(x < 0, -1, x)) | |
input_file[, unlist(lapply(input_file, is.numeric))] <- | |
apply(input_file[, unlist(lapply(input_file, is.numeric))], | |
2, | |
function(x) ifelse(x > 0, 1, x)) | |
write.csv2(input_file, | |
'data/simulation_preprocessed.csv', | |
row.names=FALSE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment