-
Notifications
You must be signed in to change notification settings - Fork 0
/
withSink.Rd
28 lines (27 loc) · 686 Bytes
/
withSink.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/server.R
\name{withSink}
\alias{withSink}
\title{Execute an expression while redirecting output to a file}
\usage{
withSink(expr, logfile = tempfile(fileext = ".txt"))
}
\arguments{
\item{expr}{The expression to execute}
\item{logfile}{The file to redirect output to. Default is "tmp.txt".}
}
\value{
The result of the expression
}
\description{
Execute an expression while redirecting output to a file
}
\examples{
logfile <- tempfile(fileext = ".txt")
withSink(logfile = logfile, expr = {
cat("Helloworld\n")
message("Goodbye")
})
readLines(logfile) == c("Helloworld", "Goodbye")
}
\keyword{internal}