get(search()[2])中的R错误:尝试从加载的包调用函数时找不到对象

时间:2014-03-28 01:59:19

标签: r

尝试使用从Cran(epicalc)下载的软件包时出现非常奇怪的错误。这个包中的一些函数工作正常,但是当我尝试调用一个特定的函数(followup.plot)时,我收到以下错误:

get(search()[2])出错:找不到对象'包:epicalc' 电话:followup.plot - >获得

任何想法意味着什么以及如何解决它?谢谢!

1 个答案:

答案 0 :(得分:1)

这似乎是一些有趣的"有趣的" followup.plot

中的代码
if (missing(xlab)) {
    xlab <- as.character(substitute(time))
    if (any(class(get(search()[2])) == "data.frame")) {
        if (any(attr(get(search()[2]), "names") == as.character(substitute(xlab)))) {
            if (!is.null(attr(get(search()[2]), "var.labels")[attr(get(search()[2]), 
              "names") == as.character(substitute(xlab))])) {
              if (attr(get(search()[2]), "var.labels")[attr(get(search()[2]), 
                "names") == as.character(substitute(xlab))] != 
                "") {
                xlab <- attr(get(search()[2]), "var.labels")[attr(get(search()[2]), 
                  "names") == as.character(substitute(xlab))]
              }
            }
        }
    }
}
if (missing(ylab)) {
    ylab <- as.character(substitute(outcome))
    if (any(class(get(search()[2])) == "data.frame")) {
        if (any(attr(get(search()[2]), "names") == as.character(substitute(ylab)))) {
            if (!is.null(attr(get(search()[2]), "var.labels")[attr(get(search()[2]), 
              "names") == as.character(substitute(ylab))])) {
              if (attr(get(search()[2]), "var.labels")[attr(get(search()[2]), 
                "names") == as.character(substitute(ylab))] != 
                "") {
                ylab <- attr(get(search()[2]), "var.labels")[attr(get(search()[2]), 
                  "names") == as.character(substitute(ylab))]
              }
            }
        }
    }
}

假设您拥有attach ed或use d变量来源。

这是非常奇怪的行为(IMHO)