demagrittr_source: Convert R's source file to non %>% code.

Description Usage Arguments Value Examples

Description

read file and convert the code which uses to flatten code

Usage

1
2
demagrittr_source(in_, out_, mode = c("eager", "lazy", "promise"),
  ask = TRUE)

Arguments

in_

file path of input.

out_

file path of output.

mode

transformed mode.

ask

ask to overwrite when 'out_“ already exists

Value

no return. side effect on a file.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
tmp_dir <- tempdir()
in_path <- file.path(tmp_dir, "test_in.r")
out_path <- file.path(tmp_dir, "test_out.r")

writeLines(
"
x <- data.frame(a = 1:5, b = 6:10)
y <- x %>%
  select(b) %>%
  filter(b >= 8)
", in_path)

demagrittr_source(in_path, out_path, ask=FALSE)

# input file
cat(paste0(readLines(in_path), collapse="\n"))
# output file
cat(paste0(readLines(out_path), collapse="\n"))

TobCap/demagrittr documentation built on May 9, 2019, 4:50 p.m.