gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 17:47:25 26 4
gpt4 key购买 nike

我不时遇到这个问题,但这是我第一次有简单的可重现示例。我相信,这个例子涉及 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com