Here’s my code
mean <- 100
sd <- 15
Fluorescence_Intensity = rnorm(x, mean, sd)
I would like to create a function that calculates Fluorescence Intensity for me where I can give and change the value of sd mean and distribution for example rnorm to dnorm.
As I am new to both R as in this forum, please help
>Solution :
This should do the job:
Fluorescence_Intensity <- function(X, MEAN, SD, METHOD){
if(METHOD=="rnorm"){
res <- rnorm(X, MEAN, SD)
}
if(METHOD=="dnorm"){
res <- dnorm(X, MEAN, SD)
}
print(res)
}
Fluorescence_Intensity(X=10, MEAN=100, SD=7, METHOD="rnorm")
Fluorescence_Intensity(X=10, MEAN=100, SD=7, METHOD="dnorm")