0

在 DRC 包中,我试图将运行 ED 函数得到的输出添加到我放置在 DRM 图上的文本框中。关于如何编写脚本的任何想法,以便我可以在文本函数中包含 ED 函数并自动将结果放置到图上?

这是我到目前为止尝试过的代码:

dayone <- structure(list(hours = c(24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 
    24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 
    24L, 24L, 24L, 24L, 24L, 24L, 24L), jarnum = c(NA_character_, 
    NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, 
    NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, 
    NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, 
    NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, 
    NA_character_, NA_character_, NA_character_, NA_character_, NA_character_, 
    NA_character_, NA_character_), treat = c(0L, 0L, 0L, 0L, 1500L, 
    1500L, 1500L, 1500L, 3000L, 3000L, 3000L, 3000L, 4000L, 4000L, 
    4000L, 4000L, 5000L, 5000L, 5000L, 5000L, 6000L, 6000L, 6000L, 
    6000L, 10000L, 10000L, 10000L, 10000L), rep = c(1L, 2L, 3L, 4L, 
    1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 
    1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), total = c(5L, 5L, 5L, 5L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L, 5L), mort = c(0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 1L, 1L, 5L, 5L, 5L, 5L, 5L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L), cummort = c(0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 1L, 1L, 5L, 5L, 5L, 5L, 5L, 5L, 
    5L, 5L, 5L, 5L, 5L, 5L)), .Names = c("hours", "jarnum", "treat", 
    "rep", "total", "mort", "cummort"), row.names = c(NA, -28L), class = c("tbl_df", 
    "tbl", "data.frame"))

drmdayone <- drm(cummort/total~treat, data=dayone, fct=LL.2(), type="binomial")
plot(drmdayone, type="all", pch=16, lwd=2,log="x", main="Acute DRC - 24 Hours",xlab="[Cl-] (mg/L)", ylab="Mortality", axes=F) 
axis(1, c(1500,3000,4000,5000,6000,10000))
axis(2, c(0,0.1,0.5,1))
text(500, 0.6, "Here is where I want the ED function (below) results to be displayed", font=2)

ED(drmdayone, c(10,50,90))
4

1 回答 1

1

不确定您希望它看起来如何,但您可以捕获函数的文本输出并直接绘制它。

text(500, .9, paste(capture.output(ED(drmdayone, c(10,50,90))), collapse="\n"))

在此处输入图像描述

于 2017-08-18T17:37:21.853 回答