Learn R Programming

formatR (version 0.2-4)

unmask.source: Restore the real source code from the masked text

Description

Remove the masks from the code to restore the real code.

Usage

unmask.source(text.mask, replace.tab = FALSE)

Arguments

text.mask
the masked source code
replace.tab
whether to replace \\t with \t

Value

  • the real source code (a character vector)

Examples

Run this code
library(formatR)

src = c("# a single line of comments is preserved", 
    "1+1", "", "if(TRUE){", "x=1  # inline comments!", "}else{", 
    "x=2;print('Oh no... ask the right bracket to go away!')}", 
    "2+2+2    # 'short comments'", "lm(y~x1+x2)  ### only 'single quotes' are allowed in comments", 
    "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1  ## comments after a long line")

x = tidy.source(text = src, output = FALSE)$text.mask

cat(x, sep = "\n")

cat(unmask.source(x), sep = "\n")

Run the code above in your browser using DataLab