evaluate icon indicating copy to clipboard operation
evaluate copied to clipboard

Sink nesting

Open tcederquist opened this issue 8 years ago • 1 comments

For some reason sink inside evaluate isn't nesting the sink statements. Is this supported or supportable? It happens in window10 and redhat7

code<-"sink.number()
sink('c:/temp/sink-example.txt')
sink.number()
i <- 1:3
outer(i, i, '*')
sink()
sink.number()"
replay(evaluate(code))

returns

> sink.number()
[1] 1
> sink('c:/temp/sink-example.txt')
> sink.number()
[1] 1
> i <- 1:10
> outer(i, i, '*')
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]    1    2    3    4    5    6    7    8    9    10
 [2,]    2    4    6    8   10   12   14   16   18    20
 [3,]    3    6    9   12   15   18   21   24   27    30
> sink()
> sink.number()
[1] 1
Warning message:
In sink() : no sink to remove

And the sink file is empty since its still writing to the evaluate's sink output.

tcederquist avatar Jul 13 '17 13:07 tcederquist

evaluate uses sink() internally. I guess this is a rather tricky issue, and I don't have time to investigate it at the moment. Sorry. If you want to hack at it by yourself, the relevant code is in https://github.com/hadley/evaluate/blob/master/R/watcher.r

yihui avatar Jul 13 '17 15:07 yihui

I don't see any way to support this due to the way that evaluate uses sink().

hadley avatar Jun 14 '24 18:06 hadley