如何将控制台的ED功能输出添加到DRM图

时间:2017-08-18 15:14:04

标签: r drc

在DRC Package中,我试图将运行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))

1 个答案:

答案 0 :(得分:1)

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

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

enter image description here