[R] need help calculating the indicator function
Rui Barradas
ru|pb@rr@d@@ @end|ng |rom @@po@pt
Sat Jan 30 05:38:01 CET 2021
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:
> Hello,
> please, I need to calculate the indicator function as I underlined in my
> attached pdf file but I can't define a code in programming language that
> deals with this case. Please help me with a code whether it's in python or
> R can help me.
>
>
>
> Sincerely.
>
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list