我具有以下自定义功能:
eulerLotka <- function(l1, l2, l3, m1, m2, m3, x1, x2, x3){
#this is the Lotka-Euler-Eq -z and z becomes 1 as uniroot finds a 0-value
y <- function(r, l1, l2, l3, m1, m2, m3, x1, x2, x3, z){((l1*m1*exp(-r*x1)) + (l2*m2*exp(-r*x2)) + (l3*m3*exp(-r*x3))) - z}
# uniroot finds a 0 value, so offset function, thats why -z in the upper formula
r <- uniroot(y, l1=l1, l2=l2, l3=l3, m1=m1, m2=m2, m3=m3, x1=x1, x2=x2, x3=x3, z = 1, interval = c(-10, 10))$root #writing only the result of r into variable
# return r into table
return(r)
} #end of eulerLotka function
我已经捕获了NA和总共0行,在此示例中未包括在内。
当我像下面这样将函数应用于data.frame
时,uniroot
会引发错误:
my_data$population_growth_rate <- eulerLotka(my_data$survival_c1, my_data$cum_survival_c2, my_data$cum_survival_c3, my_data$offspring_c1, my_data$offspring_c2, my_data$offspring_c3, my_data$day_c1, my_data$day_c2, my_data$day_c3)
但是,如果我在循环中调用该函数,它将很好地工作:
for (i in 1:length(my_data$beaker_NO)){
my_data$population_growth_rate[i] <- eulerLotka(my_data$survival_c1[i], my_data$cum_survival_c2[i], my_data$cum_survival_c3[i], my_data$offspring_c1[i], my_data$offspring_c2[i], my_data$offspring_c3[i], my_data$day_c1[i], my_data$day_c2[i], my_data$day_c3[i])
}
为什么会这样,我该怎么做而没有循环调用该函数?
我已经尝试过在寻找解决方案时发现的apply
和mapply
。两者均未成功(uniroot
再次引发错误)。
我想我错过了一些愚蠢的东西,但是找不到。我将不胜感激任何想法或帮助:)
编辑: 这是要求的my_data(希望这是正确的发布方式):
structure(list(beaker_NO = 1:120, treat_comp = structure(c(7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L
), .Label = c("Dm_LM0", "Dm_LM10", "Dm_LM100", "Dm_LM15", "Dm_LM20",
"Dm_LM5", "Dm_UM0", "Dm_UM10", "Dm_UM100", "Dm_UM15", "Dm_UM20",
"Dm_UM5"), class = "factor"), treatment = structure(c(2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L
), .Label = c("0_Scen_LM", "0_Scen_UM", "10_Scen_LM", "10_Scen_UM",
"100_Scen_LM", "100_Scen_UM", "15_Scen_LM", "15_Scen_UM", "20_Scen_LM",
"20_Scen_UM", "5_Scen_LM", "5_Scen_UM"), class = "factor"), repl_NO = c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L,
7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), X1 = c(NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA), X2 = c(NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA), X3 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), X4 = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L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 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 7L, 1L, 1L, 1L), .Label = c("", "10", "11", "5", "6",
"7", "8", "9", "x"), class = "factor"), X11 = c(NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 2L, NA, NA, NA, NA, NA,
1L, 2L, NA, 12L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, 1L, NA, NA, NA, 2L, NA, 4L,
3L, NA, 3L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), X12 = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L,
1L, 1L, 1L, 1L, 5L, 1L, 1L, 6L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
8L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 7L, 5L, 4L, 3L, 2L, 5L, 1L, 5L, 7L, 6L), .Label = c("",
"1", "11", "12", "13", "14",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,
7L, 8L, 5L), .Label = c("", "08. Jan", "09. Jan", "1", "10",
"10. Jan", "11", "12", "5", "7", "8", "9"), class = "factor"),
X17 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, 2L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
5L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA), X18 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 3L, 1L, 3L, 1L, 6L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 5L, 4L, 1L, 3L, 1L, 4L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("", "03. Jan", "2",
"3", "4", "8"), class = "factor"), X19 = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 10L, 1L, 2L, 6L, 2L, 2L, 2L, 7L, 4L, 2L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 11L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 8L, 5L, 9L, 4L, 2L, 6L, 3L, 4L, 7L,
7L), .Label = c("", "10", "10. Jan", "11", "11. Jan", "12",
"13", "14", "15", "9", "x"), class = "factor"), X20 = c(NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
day_c1 = c(21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, NA, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
11, 21, 12, 21, 21, 21, 11, 11, 9, 11, 10, 9, 10, 10, 9,
9.5, 10, 10, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 11,
21, 21, 21, 11, 21, 11, 11, 21, 11, 9, 9, 9, 9, 9, 9, 10,
9, 9, 9), day_c2 = c(21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
NA, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 15, 21, 21, 21, 21, 21, 21, 21, 21, 21, 12, 14, 13, 12.5,
13, 13, 13, 13, 13, 13, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 15, 21, 21, 21,
15, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 12, 12, 12, 12,
12.5, 12, 13, 12.5, 12, 12), day_c3 = c(21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, NA, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 21, 18,
16, 18, 16, 16, 16, 16, 16, 16, 16, 16, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 17, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 17, 17, 17, 21, 17, 21, 17,
16, 16, 16, 16, 16, 15.5, 16, 16, 16, 16), offspring_c1 = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
0, 0), day_of_death = c(21L, 15L, 13L, 10L, 13L, 13L, 4L,
13L, 9L, 6L, 21L, 21L, 7L, 5L, 6L, 14L, 8L, 14L, 21L, 21L,
8L, 21L, 21L, 21L, NA, 21L, 6L, 21L, 21L, 21L, 6L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 6L, 12L, 8L, 6L, 6L, 13L, 21L, 6L, 19L, 13L,
13L, 8L, 8L, 6L, 7L, 21L, 15L, 7L, 21L, 21L, 21L, 6L, 21L,
21L, 7L, 6L, 21L, 5L, 6L, 21L, 21L, 21L, 21L, 7L, 21L, 21L,
21L, 21L, 7L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L
), survival_c1 = c(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4,
0.7, 0.7, 0.7, 0.7, NA, 0.7, 0.7, 0.7, 0.7, 0.7, 0.9, 0.9,
0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.3, 0.3, 0.3, 0.3, 0.3,
0.3, 0.3, 0.3, 0.3, 0.3, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,
0.5, 0.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7, 0.7, 0.7, 0.7, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9,
0.9, 0.9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.5,
0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.8, 0.8, 0.8,
0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), population_growth_rate = c(-0.548253280611676,
-0.548253280611676, -0.548253280611676, -0.548253280611676,
-0.548253280611676, -0.548253280611676, -0.548253280611676,
-0.548253280611676, -0.548253280611676, -0.548253280611676,
-0.482227712193977, -0.482227712193977, -0.482227712193977,
-0.482227712193977, -0.482227712193977, -0.482227712193977,
-0.482227712193977, -0.482227712193977, -0.482227712193977,
-0.482227712193977, -0.455588251976892, -0.455588251976892,
-0.455588251976892, -0.455588251976892, NA, -0.455588251976892,
-0.455588251976892, -0.455588251976892, -0.455588251976892,
-0.455588251976892, -0.443604910088864, -0.443604910088864,
-0.443604910088864, -0.443604910088864, -0.443604910088864,
-0.443604910088864, -0.443604910088864, -0.443604910088864,
-0.443604910088864, -0.443604910088864, 0.0732504452718779,
-0.438585510194361, 0.0630203252486924, -0.438585510194361,
3.05175781232237e-05, -0.438585510194361, 0.0610329340997982,
0.0385086076720785, 3.05175781232237e-05, 0.0997535394873194,
0.320665252448158, 0.263992429172323, 0.245636890618122,
0.333716575510355, 0.261623823826246, 0.250156804597224,
0.291453243444366, 0.289101944297742, 0.285745201520734,
0.278889498531854, -0.548253280611676, -0.548253280611676,
-0.548253280611676, -0.548253280611676, -0.548253280611676,
-0.548253280611676, -0.548253280611676, -0.548253280611676,
-0.548253280611676, -0.548253280611676, -0.495940836214367,
-0.495940836214367, -0.495940836214367, -0.495940836214367,
-0.495940836214367, -0.495940836214367, -0.495940836214367,
-0.495940836214367, -0.495940836214367, -0.495940836214367,
-0.471584005671505, -0.471584005671505, -0.471584005671505,
-0.471584005671505, -0.471584005671505, -0.471584005671505,
-0.471584005671505, -0.471584005671505, -0.471584005671505,
-0.471584005671505, -0.449211272694424, 0.0276500457436783,
-0.449211272694424, -0.449211272694424, -0.449211272694424,
-0.449211272694424, -0.449211272694424, -0.449211272694424,
-0.449211272694424, -0.0148842546964249, 3.05175781232237e-05,
-0.438585510194361, -0.438585510194361, 0.0946652221771135,
0.123797410919051, 0.0646217990911813, 0.126026108030958,
0.124789630103426, -0.438585510194361, 0.133570171501455,
0.315069928471503, 0.321809820397907, 0.307588632905269,
0.299613831920816, 0.286072252121948, 0.311803578708894,
0.269097760860433, 0.312118094806563, 0.331347291564091,
0.317866549798655)), row.names = c(NA, -120L), class = "data.frame")
编辑2: 如果您想使用原始数据,则必须使用以下版本的自定义函数:
eulerLotka <- function(l1, l2, l3, m1, m2, m3, x1, x2, x3){
#if one of those values is NA, return NA and don't calculate anything
if(is.na(l1) || is.na(l2) || is.na(l3) || is.na(m1) || is.na(m2) || is.na(m3) || is.na(x1) || is.na(x2) || is.na(x3)){
return (NA)
}
# if all 3 values of a parameter are 0, the function will set one to 0.0001 (otherwise it won't work)
if(l1 == 0 && l2 == 0 && l3 == 0){
l3 <- 0.0001
}
if(m1 == 0 && m2 == 0 && m3 == 0){
m3 <- 0.0001
}
if(x1 == 0 && x2 == 0 && x3 == 0){
x3 <- 0.0001
}
#this is the Lotka-Euler-Eq -z and z becomes 1 as uniroot finds a 0-value
y <- function(r, l1, l2, l3, m1, m2, m3, x1, x2, x3, z){((l1*m1*exp(-r*x1)) + (l2*m2*exp(-r*x2)) + (l3*m3*exp(-r*x3))) - z}
# uniroot finds a 0 value, so offset function, thats why -z in the upper formula
r <- uniroot(y, l1=l1, l2=l2, l3=l3, m1=m1, m2=m2, m3=m3, x1=x1, x2=x2, x3=x3, z = 1, interval = c(-10, 10))$root #writing only the result of r into variable
# return r into table
return(r)
} #end of eulerLotka function
答案 0 :(得分:1)
您可以使用purrr::pmap()
函数来做到这一点:
library(tidyverse)
library(magrittr)
my_data$population_growth_rate <-
my_data %$%
pmap_dbl(list(
survival_c1, cum_survival_c2, cum_survival_c3,
offspring_c1, offspring_c2, offspring_c3,
day_c1, day_c2, day_c3
),
eulerLotka
)