Skip to contents

Remove comments from code text

Usage

code_remove_comments(
  code_text,
  lang = c("R", "Python", "SPSS", "SAS", "Stata", "Mplus", "MATLAB")
)

Arguments

code_text

the code text for a single file

lang

the language (we only currently handle R, Python, SPSS, SAS, Stata, Mplus, MATLAB)

Value

the code_text minus comment lines

Examples

code_text <- c(
  "# this is a comment",
  "",
  "x <- 'And this is code'"
)
code_text_nc <- code_remove_comments(code_text, "R")