Consider this code. This is R 3.4.2, but based on a quick look at the
NEWS, this has not been fixed.
tryCatch(
readLines(tempfile(), warn = FALSE)[1],
error = function(e) NA,
warning = function(w) NA
)
rm(list=ls(all.names = TRUE))
gc()
showConnections(all = TRUE)
If you run it, you'll ge
Gabor,
You can grab the connection and destroy it via getConnection and then a
standard close call. (it actually lists that it is "closed" already, but
still in the set of existing connections. I can't speak to that difference).
> tryCatch(
+ readLines(tempfile(), warn = FALSE)[1],
+ error
Hi All,
I asked this over at r-help, but didn't get any responses. As this seems like a
bug (or at least undocumented behavior) to me, I'll try again here.
It seems to me that xyTable() gets thrown off by NAs:
x <- c(1, 1, 2, 2, 2, 3)
y <- c(1, 2, 1, 3, NA, 3)
table(x, y, useNA="always")
xyTab
On Thu, Dec 14, 2017 at 7:56 PM, Gabriel Becker wrote:
> Gabor,
>
> You can grab the connection and destroy it via getConnection and then a
> standard close call.
Yeah, that's often a possible workaround, but since this connection
was opened by
readLines() internally, I don't necessarily know whi
On Thu, Dec 14, 2017 at 12:17 PM, Gábor Csárdi
wrote:
> On Thu, Dec 14, 2017 at 7:56 PM, Gabriel Becker
> wrote:
> > Gabor,
> >
> > You can grab the connection and destroy it via getConnection and then a
> > standard close call.
>
> Yeah, that's often a possible workaround, but since this connec
Your guess is wrong. More when I have a sensible keyboard
Sent from my iPhone
On Dec 15, 2017, at 10:21 AM, Gabriel Becker
mailto:gmbec...@ucdavis.edu>> wrote:
On Thu, Dec 14, 2017 at 12:17 PM, Gábor Csárdi
mailto:csardi.ga...@gmail.com>>
wrote:
On Thu, Dec 14, 2017 at 7:56 PM, Gabriel Becker
Hi,
Here is how to reproduce:
With a matrix of atomic type
m1 <- matrix(1:12, ncol=3,
dimnames=list(letters[1:4], LETTERS[1:3]))
typeof(m1)
# [1] "integer"
m1
# A B C
# a 1 5 9
# b 2 6 10
# c 3 7 11
# d 4 8 12
format(m1)
#
This has nothing to do with on.exit. It is an iteraction between where
the warning is signaled in 'file' and your _exiting_ warning handler.
This combination has the same issue,
tryCatch(file(tempfile(), "r"), warning = identity)
showConnections(all = TRUE)
as does
options(warn=2)
file(tempfile
Thanks for tracking this down. Yeah, I should use suppressWarnings(),
you are right.
Although, readLines() might throw another warning, e.g. for incomplete
last lines,
and you don't necessarily want to suppress that.
TBH I am not sure why that warning is given:
❯ con <- file(tempfile())
❯ open(co