Reputation: 2764
I have a function which prints required output in R console
, but what I am trying, is to get same output as a source code in a source pane
of a RStudio
.
Sample function -
# Declare params for plumber api script----------------------------------
input <- c("A","B","C")
sample_print <- function(input){
cat(for (i in length(input):1) {
cat("\n#' @param", input[i], sep =" " )
},
"\n#* @post /",
sep = "")
}
sample_print(input)
Output-
> sample_print(input)
#' @param C
#' @param B
#' @param A
#* @post /
Note- I know its possible to copy/paste
it. But, I have large output text and I am looking for a feasible method.
Upvotes: 1
Views: 833
Reputation: 76
You can first save your script in text format and use sink() function. Please refer to this link https://www.statmethods.net/interface/io.html
Upvotes: 1