2
I have a vector of integer values in R, for example:
y = c(rep(1:4, c(36,9,2,1)), 6, 6)
and I need to make a sum within a function, like this:
that is, I need to do
36*funcao_f(1,phi)+9*funcao_f(2,phi)+...
considering, for example:
phi = 1
funcao_f = function(I,PHI)(I*(I-1))/(1+(I*PHI))
How do I do this in R, given a random y vector (which I don’t necessarily know how much of each generated value I have, but R will calculate the n_i for me, identifying i=1, or i = 2... in my y vector)?
Thanks a lot of people Good to R!!!