#!/usr/bin/env Rscript args <- commandArgs(trailingOnly=TRUE) path <- args[1] start <- as.numeric(args[2]) end <- as.numeric(args[3]) out <- args[4] #"./out.txt" tad <- data.table::fread(path, header = TRUE , sep = ' ') xaxis <- tad[,1] xmax <- max(xaxis) newxaxis <- lapply(xaxis, function(x){ new_x <- (((end - start) * x) / xmax) + start }) tad[,1] <- round(unlist(newxaxis[1])) data.table::fwrite(tad, file = out, col.names = TRUE, sep = ' ', quote = FALSE)