
args=commandArgs(TRUE)

# Packages to load #######
library(gtools)
library(data.table)

removeZeroVar3 <- function(df){
  df[, !sapply(df, function(x) min(x) == max(x))]
}

indir <- args[1] 

f1 <- fread(indir, sep=' ', header=FALSE)
label <- f1[[1]]
f2 <- f1[,V1:=NULL]

f3 <- removeZeroVar3(f2)

wh <- which(f3 == TRUE)

f4 <- f2[, ..wh]

f5 <- cbind(data.frame(label), f4)

write.table(f5, args[2], quote=FALSE, sep=' ', col.names=FALSE, row.names=FALSE)
