diff --git a/R/reprex-undo.R b/R/reprex-undo.R index c71824ff..8012764e 100644 --- a/R/reprex-undo.R +++ b/R/reprex-undo.R @@ -37,10 +37,9 @@ NULL #' #' More text #' y <- 2:5 #' x + y -#' }, show = FALSE, advertise = FALSE) -#' writeLines(x) -#' x <- reprex_invert(x) -#' writeLines(x) +#' }, show = FALSE, advertise = FALSE, outfile = "roundtrip-input") +#' x <- reprex_invert(x, outfile = "roundtrip-output") +#' x #' } reprex_invert <- function(input = NULL, outfile = NULL, @@ -78,8 +77,8 @@ reprex_invert <- function(input = NULL, #' "median(x)", #' "#> [1] 2.5" #' ) -#' out <- reprex_clean(x) -#' writeLines(out) +#' out <- reprex_clean(x, outfile = "commented-code") +#' out #' #' ## round trip with reprex(..., venue = "R") #' code_in <- c("x <- rnorm(2)", "min(x)") @@ -109,8 +108,8 @@ reprex_clean <- function(input = NULL, #' "> median(x)", #' "[1] 2.5" #' ) -#' out <- reprex_rescue(x) -#' writeLines(out) +#' out <- reprex_rescue(x, outfile = "live-transcript") +#' out #' } reprex_rescue <- function(input = NULL, outfile = NULL, diff --git a/docs/reference/un-reprex.html b/docs/reference/un-reprex.html index c81b2f06..a6c03325 100644 --- a/docs/reference/un-reprex.html +++ b/docs/reference/un-reprex.html @@ -177,10 +177,9 @@

Examp #' More text y <- 2:5 x + y -}, show = FALSE, advertise = FALSE) -writeLines(x) -x <- reprex_invert(x) -writeLines(x) +}, show = FALSE, advertise = FALSE, outfile = "roundtrip-input") +x <- reprex_invert(x, outfile = "roundtrip-output") +x # }# NOT RUN { ## a displayed reprex can be cleaned of commented output x <- c( @@ -190,8 +189,8 @@

Examp "median(x)", "#> [1] 2.5" ) -out <- reprex_clean(x) -writeLines(out) +out <- reprex_clean(x, outfile = "commented-code") +out ## round trip with reprex(..., venue = "R") code_in <- c("x <- rnorm(2)", "min(x)") @@ -208,8 +207,8 @@

Examp "> median(x)", "[1] 2.5" ) -out <- reprex_rescue(x) -writeLines(out) +out <- reprex_rescue(x, outfile = "live-transcript") +out # }