如何在软件包内找到自定义绘图函数的根过程[重复]

问题描述 投票:0回答:0
在我的理解中,一些自定义的对象类具有自定义的
plot
函数,该功能允许使用

plot(object_name)

并获取您(很可能)感兴趣的绘图。
,例如,我可以从类似下面的代码的“ help”页面上获取
pmcalibration::pmcalibration

如图所示,

library(pmcalibration)
library(survival)
  
data('transplant', package="survival")
transplant <- na.omit(transplant)
transplant = subset(transplant, futime > 0)
transplant$ltx <- as.numeric(transplant$event == "ltx")
  
cph <- coxph(Surv(futime, ltx) ~ age + sex + abo + year, data = transplant)
  
time <- 100
newd <- transplant; newd$futime <- time; newd$ltx <- 1
p <- 1 - exp(-predict(cph, type = "expected", newdata=newd))
y <- with(transplant, Surv(futime, ltx))
  
cal <- pmcalibration(y = y, p = p, smooth = "rcs", nk=5, ci = "pw", time = time)

class(cal)
  [1] "pmcalibration"

plot(cal)
具有“ PMCALIBRATION”类,足以将其作为

cal
函数的参数,以获取您几乎可以肯定您对使用
plot

函数

的校准图。
我的问题是:我如何检索这里完成了什么功能?如何获得使用
pmcalibration
中的哪些值和变量来创建图?下面发生了什么?
对于这个特定示例,我可以看到本节的存在可能给出一个提示。但是,我仍然无法理解已使用了哪些变量,并且已将哪些函数应用于存储的值最终能够创建绘图。
	
您可以使用

plot

查看使用了哪种方法,

cal
并有很好的猜测包,请检查(可能非出口)源代码。
cal$plot

r plot
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.