r - "could not find function"仅在 R 调试器中时

标签 r debugging

我不时遇到这个问题,但这是我第一次有简单的可重现示例。我相信,这个例子涉及 lubridate 的事实是巧合。在 R --vanilla session 中

library(lubridate)
ymd("2001-02-02")
# [1] "2001-02-02 UTC"
# so far so good
debug(ymd)
ymd("2001-02-02")
# debugging in: ymd("2001-02-02")
# Error in ymd("2001-02-02") : could not find function ".parse_xxx"

ymd 没有错,我正在努力学习一些东西。但是当你真正调试的时候出现这种情况,就很烦人了。调试器错误还是我遗漏了什么?

版本信息
    > R.version
               _                           
platform       x86_64-apple-darwin13.4.0   
arch           x86_64                      
os             darwin13.4.0                
system         x86_64, darwin13.4.0        
status                                     
major          3                           
minor          1.2                         
year           2014                        
month          10                          
day            31                          
svn rev        66913                       
language       R                           
version.string R version 3.1.2 (2014-10-31)
nickname       Pumpkin Helmet  

根据@Joshua Urlich 评论的 session 信息
  > sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lubridate_1.3.3

loaded via a namespace (and not attached):
[1] digest_0.6.4  memoise_0.2.1 plyr_1.8.1    Rcpp_0.11.3   stringr_0.6.2

谢谢

最佳答案

看起来它可能与未使用 {} 定义的函数有关。 .目前的实现是:

ymd <- function(..., quiet = FALSE, tz = "UTC", locale = Sys.getlocale("LC_TIME"),  truncated = 0)
  .parse_xxx(..., orders = "ymd", quiet = quiet, tz = tz, locale = locale,  truncated = truncated)

您的 debug如果我解压源代码并将实现更改为:
ymd <- function(..., quiet = FALSE, tz = "UTC", locale = Sys.getlocale("LC_TIME"),  truncated = 0)
{  .parse_xxx(..., orders = "ymd", quiet = quiet, tz = tz, locale = locale,  truncated = truncated)}

在进行上述更改之前,我能够复制该问题。制作完成后,我得到:
> require(lubridate); debug(ymd); ymd("2015-01-01")
Loading required package: lubridate
debugging in: ymd("2015-01-01")
debug: {
    .parse_xxx(..., orders = "ymd", quiet = quiet, tz = tz, locale = locale, 
        truncated = truncated)
}
Browse[2]> 
debug: .parse_xxx(..., orders = "ymd", quiet = quiet, tz = tz, locale = locale, 
    truncated = truncated)
Browse[2]> 
exiting from: ymd("2015-01-01")
[1] "2015-01-01 UTC"

关于r - "could not find function"仅在 R 调试器中时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29306027/

相关文章:

r - 将秒转换为天 : hours:minutes:seconds

c++ - 设置 ifstream,获取 'error: expected initializer before ‘.’ token '

html - 如何在 IE 和 Mozilla 中查看完整的源代码

debugging - 如何检测MinGW下的堆损坏错误?

r - 如何在 ggplot 函数中使用以数字开头的列名

r - ggplot2 绘制日期数据的错误——缺少需要 TRUE/FALSE 的值

r - Purrr-Fection : In Search of An Elegant Solution to Conditional Data Frame Operations Leveraging Purrr

r - 清除 R 工作区

debugging - TypeScript 和 Visual Studio 2015 断点 - 没有为该文档加载任何符号

debugging - 有没有办法用 testcafe 和 VS Code 找到 Selector 的运行时值