I have my code:
V <- function(c, E, HS, EC_50) E (1 - E) / (1 exp(HS * (c - EC_50)))
HS <- 1
log_EC50 <- log(1e-3)
E <- 0
log_c <- seq(-12, 0, by = 0.1)
response = V(log_c, E, HS, log_EC50)
mean_to_hist <- mean(response)
sd_to_hist <- 1
I want to create a function that do the same stuff as my function V in my code show response and additionally calculate mean like mean_to_hist and I can give sd as parmatr (which is in advance daye and not calculated). I'm not sure how to do it, so please help me
CodePudding user response:
You can create a list in the function:
V <- function(C, E, HS, EC_50) {
response <- E (1 - E) / (1 exp(HS * (C - EC_50)))
list(response = response,
mean_to_hist = mean(response),
sd_to_hist = 1)
}
output
V(seq(-12, 0, by = 0.1), 0, 1, log(1e-3))
$response
[1] 0.993893308 0.993255394 0.992551341 0.991774402
[5] 0.990917166 0.989971496 0.988928466 0.987778294
[9] 0.986510265 0.985112659 0.983572664 0.981876298
[13] 0.980008317 0.977952130 0.975689706 0.973201487
[17] 0.970466301 0.967461283 0.964161799 0.960541387
[21] 0.956571711 0.952222537 0.947461732 0.942255302
[25] 0.936567469 0.930360792 0.923596355 0.916234010
[29] 0.908232710 0.899550919 0.890147118 0.879980416
[33] 0.869011260 0.857202265 0.844519134 0.830931685
[37] 0.816414954 0.800950358 0.784526889 0.767142290
[41] 0.748804181 0.729531069 0.709353187 0.688313112
[45] 0.666466090 0.643880023 0.620635089 0.596822953
[49] 0.572545589 0.547913705 0.523044842 0.498061190
[53] 0.473087216 0.448247194 0.423662744 0.399450485
[57] 0.375719888 0.352571419 0.330095031 0.308369038
[61] 0.287459396 0.267419376 0.248289611 0.230098469
[65] 0.212862710 0.196588349 0.181271699 0.166900497
[69] 0.153455093 0.140909639 0.129233245 0.118391069
[73] 0.108345331 0.099056221 0.090482706 0.082583226
[77] 0.075316291 0.068640968 0.062517283 0.056906531
[81] 0.051771521 0.047076743 0.042788488 0.038874919
[85] 0.035306094 0.032053970 0.029092373 0.026396948
[89] 0.023945096 0.021715903 0.019690052 0.017849742
[93] 0.016178595 0.014661571 0.013284874 0.012035867
[97] 0.010902991 0.009875681 0.008944291 0.008100024
[101] 0.007334858 0.006641490 0.006013269 0.005444146
[105] 0.004928621 0.004461693 0.004038822 0.003655882
[109] 0.003309130 0.002995168 0.002710913 0.002453568
[113] 0.002220599 0.002009706 0.001818805 0.001646007
[117] 0.001489602 0.001348039 0.001219913 0.001103951
[121] 0.000999001
$mean_to_hist
[1] 0.4253818
$sd_to_hist
[1] 1