Skip to content

Commit

Permalink
R equivalent
Browse files Browse the repository at this point in the history
  • Loading branch information
olgatsiouri1996 authored Nov 3, 2020
1 parent dc28f6d commit 2dc5c7f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions text_manipulation/print_or_remove_lines_by_pattern.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env Rscript
library(glue)
library(stringr)
args = commandArgs(trailingOnly=TRUE)
glue("usage: print_or_remove_lines_by_pattern.R input_txt column_name pattern boolean_print_or_remove output_txt")
# main
input_txt <- read.delim(args[1], header= as.logical(args[2]))
filtered_txt <- input_txt[str_detect(input_txt[ ,as.numeric(args[3])], args[4], negate = as.logical(args[5])), ]
write.table(filtered_txt, file = args[6],quote = FALSE,row.names = FALSE,sep = "\t",eol = "\n")

0 comments on commit 2dc5c7f

Please sign in to comment.