I am trying to call the timestamp
function in Rstudio but seem to be calling a version other than the one I want. getAnywhere
shows that there are 2 definitions:
> getAnywhere(timestamp)
2 differing objects matching ‘timestamp’ were found
in the following places
package:utils
namespace:utils
Use [] to view one of them
> timestamp
function(...) .rs.callAs(name,
hook,
original,
...)
<environment: 0x0000000005f42030>
> timestamp()
##------ Thu Mar 06 15:08:51 2014 ------##
> utils::timestamp
function (stamp = date(), prefix = "##------ ", suffix = " ------##",
quiet = FALSE)
{
stamp <- paste0(prefix, stamp, suffix)
.External2(C_addhistory, stamp)
if (!quiet)
cat(stamp, sep = "\n")
invisible(stamp)
}
<bytecode: 0x0000000005f447a8>
<environment: namespace:utils>
Calling utils::timestamp()
crashes RStudio. If I just call timestamp
, it seems to ignore the parameters, though.
> timestamp(prefix = "##-ddg-- ", quiet=TRUE)
This does not change the prefix associated with the timestamp
, and it returns output to the console, which it should not do when quiet is true.
This is running R 3.0.1, RStudio 0.97.551, Windows 7 Enterprise service pack 1.
On my Mac, getAnywhere
gives a slightly different result and the timestamp
function works correctly.
> getAnywhere(timestamp)
A single object matching ‘timestamp’ was found
It was found in the following places
package:utils
namespace:utils
with value
function (stamp = date(), prefix = "##------ ", suffix = " ------##",
quiet = FALSE)
{
stamp <- paste0(prefix, stamp, suffix)
.External2(C_addhistory, stamp)
if (!quiet)
cat(stamp, sep = "\n")
invisible(stamp)
}
<bytecode: 0x7fd90b10bdb8>
<environment: namespace:utils>
Where is this second definition coming from on Windows? How do I get R to call the right version?
Thanks for your help.
Barbara
In the comments Jonathan answers the Where is this second definition coming from on Windows? and crashing parts of the question with
On Windows RStudio replaces timestamp with its own method because the default method has dependencies that aren't met in the RStudio environment (which is what causes the crash you see when you invoke it directly). Its method is a replacement for timestamp, however, not a wrapper, and the replacement doesn't support all the parameters of the original. I'd encourage you to report the problem on the RStudio support forum.
Which you have confirmed on the RStudio Support page. It is also reported on an earlier RStudio support thread.
Unfortunately, RStudio's bug database looks to be internal so you will need to monitor it by following the commit history or the Release Notes for the latest version or the preview release.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With