Suppose, I have a data set like,
y <- c(0,0,1,2,2,1,0,1)
a <- c(0,2,1,1,0,2,0,3)
dat <- data.frame(y, a)
I want to calculate the value of f <- digamma(a+y) by using the condition
if(a>0 & y==0) then f
if(a==0 & y>0) then f
if (a==0 & y==0) then f = 1
How can I do it using R code?
I think this will give you what you’re after post hoc:
or
Well this is using indexing to see which elements in the vector are nan or in the first method both a and y are 0. Then the index
[]says take these elements of f and the assignment<-says make these elements a one.