evaluate
evaluate copied to clipboard
Sink nesting
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.
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
I don't see any way to support this due to the way that evaluate uses sink().