Message-ID: <CAFDcVCTOCzGZYoZjGPxbkv+h_CJyLQ=4zNGwrfV351RkETw07g@mail.gmail.com>
Date: 2014-04-07T04:33:15Z
From: Henrik Bengtsson
Subject: attach() outputs messages to stdout - should it be stderr?
Contrary to other functions in 'base', attach() output messages to
stdout instead of stdout, e.g.
> a <- 1
> capture.output(attach(list(a=1)))
[1] "The following object is masked _by_ .GlobalEnv:"
[2] ""
[3] " a"
Shouldn't this message go to stderr?
Here's a patch for the local function checkConflicts() of
base::attach(), cf. ditto for base::library() that outputs to stderr:
Index: library/base/R/attach.R
===================================================================
--- library/base/R/attach.R (revision 65344)
+++ library/base/R/attach.R (working copy)
@@ -73,7 +73,7 @@
"The following objects
are masked %s %s:\n\n%s\n"),
if (i < db.pos) "_by_" else "from",
pkg, paste(objs, collapse="\n"))
- cat(msg)
+ cat(msg, file = stderr())
}
}
}
/Henrik