Skip to content
Prev 387051 / 398502 Next

need help calculating the indicator function

Hello,

Maybe this?

n_l <- function(Y, l, na.rm = FALSE) sum(Y == l, na.rm = na.rm)

set.seed(2020)
q <- 6
y <- sample(q, 10, TRUE)

l <- 4
n_l(y, l)
#[1] 3


Hope this helps,

Rui Barradas


?s 14:27 de 29/01/21, Ablaye Ngalaba escreveu: